Sha256: d3a2bcd302ef8fb09be4546979a2140465f5759d03750b568e5ebcb799994497

Contents?: true

Size: 1.19 KB

Versions: 7

Compression:

Stored size: 1.19 KB

Contents

=RSolr::Ext
A set of helper methods/modules to assist in building Solr queries and handling responses when using the RSolr library.

==Request Example
  solr_params = {
    :page=>2,
    :per_page=>10,
    :phrases=>{:name=>'This is a phrase'},
    :filters=>['test', {:price=>(1..10)}],
    :phrase_filters=>{:manu=>['Apple']},
    :queries=>'ipod',
    :facets=>{:fields=>['cat', 'blah']}
  }
  
  rsolr = RSolr::Ext.connect
  
  response = rsolr.select(solr_params)

==Response Example
  rsolr = RSolr::Ext.connect
  
  response = rsolr.select(:q=>'*:*)
  
  response.ok?
  response.params
  response.docs
  response.docs.previous_page
  response.docs.next_page
  response.facets

You can access values in the response hash using symbols or strings.

===Doc Pagination
If you wanna paginate, just throw the collection into the WillPaginate view helper.
  <%= will_paginate response.docs %>

===The Doc Module
You can create your own "models" using RSolr::Ext::Doc

  class Book
    include RSolr::Ext::Doc
    def self.find_by_author(author)
        find(:fq=>'object_type:"book"', :rows=>10, :phrase_filters=>{:author=>author})
    end
  end
  
  all_books = Book.find('*:*')
  hawk_books = Book.find_by_author('hawk')

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
mwmitchell-rsolr-ext-0.7.3 README.rdoc
mwmitchell-rsolr-ext-0.7.31 README.rdoc
mwmitchell-rsolr-ext-0.7.32 README.rdoc
mwmitchell-rsolr-ext-0.7.33 README.rdoc
mwmitchell-rsolr-ext-0.7.34 README.rdoc
mwmitchell-rsolr-ext-0.7.35 README.rdoc
mwmitchell-rsolr-ext-0.7.4 README.rdoc