Coder Social home page Coder Social logo

solrmapper's Introduction

SolrMapper

An ORM for Solr documents.

Build Status

Installation & Configuration

Currently, SolrMapper is under active development, and is not ready even for beta use. That said, if you're interested in living on the bleeding edge, you can install the gem from source.

Gemfile
gem 'solrmapper', :git => 'git://github.com/nz/solrmapper.git'

Indexing documents

You can use the SolrMapper::Document class directly…

doc = SolrMapper::Document.new(
  :title => "Hello world!",
  :content => "My name is Frederick."
)
doc.save

SolrMapper::Document feels a lot like ActiveRecord. And, indeed, it is build on many of the same fundamentals provided by ActiveModel and ActiveSupport.

Use your own classes

class Document < SolrMapper::Document
end

doc = Document.create(
  :title => "TPS Report #3423"
)

Solr field names

The attribute names given to your documents are expected to match the definitions in your Solr schema.xml.

Coming soon...

Searching for documents

Simple search

Just give your query to the search class method.

@search = Document.search('hello world')

Filter queries and other Solr paramters

You can also provide the search class method with a hash that will be serialized into Solr parameters. If you're familiar with Solr, then this is just the method you're looking for.

@search = Document.search(
  :q => 'hello world',
  :fq => { :category => 'Cheerful' }
)

Chainable search methods

@search = Document.search('hello world').
                   where(category: 'Cheerful').
                   facet(field: 'category').
                   mm(1)

First-class facets

@search = Document.facet(fields: %w(category author))

@search.facets.each do |facet|
  puts facet.field
  facet.terms.each do |term, count|
    puts "  #{term}: #{count}"
  end
  puts
end

The above would print something like the following...

Category
  Cheerful: 23
  Gloomy: 12
Author
  e.e. cummings: 14
  T.S. Eliot: 10

solrmapper's People

Contributors

nz avatar

Stargazers

 avatar

Watchers

 avatar James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.