Security News
Bun 1.2 Released with 90% Node.js Compatibility and Built-in S3 Object Support
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
=RSolr::Ext A set of helper methods/modules to assist in building Solr queries and handling responses when using the RSolr library.
== Installation: gem sources -a http://gemcutter.org sudo gem install rsolr-ext
==Related Resources & Projects
==Requests To use the RSolr::Ext connection instead of the normal RSolr connection just require 'rsolr-ext': require 'rsolr-ext' solr = RSolr::Ext.connect
RSolr::Ext adds a #find and a #luke method to the connection object.
===#luke The #luke method returns a Hash/Mash result of a /admin/luke?numTerms=0 request: luke_response = solr.luke luke_response['index'] luke_response['fields'] luke_response['info']
===#find The #find method listens for certain keys. All other keys are ignored, allowing the ability to mix-and-match special keys with normal Solr param keys. The recognized keys are describe below.
:page - This maps to the Solr "start" param. The current "page" in the results set. RSolr::Ext handles the page-to-rows math for you.
:per_page - This maps to the Solr "rows" param. How many "pages" in the result.
:queries - This key maps to the Solr "q" param. Accepts a string, array or hash. When an array is used, each value is joined by a space. When a hash is used, the keys are used as Solr fields.
:phrases - This value is mapped to the Solr "q" param. When this key is used, the value will become double-quoted, creating a Solr "phrase" based query.
:filters - The :filters key maps to the Solr :fq param. This has the same behavior as the :queries key, except it's for the :fq param.
:phrase_filters - The :phrase_filters key maps to the Solr :fq param. This has the same behavior as the :phrases key, except it's for the :fq param.
:facets - The :facets does a few different things. First, it sets the Solr param facet=true. It accepts a hash with a single key called :fields. This should be an array of field names to facet on.
==Request Example require 'rsolr-ext' solr = RSolr::Ext.connect 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']}, :echoParams => 'EXPLICIT' } response = rsolr.find solr_params, :method => :post
==Responses RSolr::Ext decorates the normal output hash from RSolr and adds some helpful methods.
require 'rsolr-ext' solr = RSolr::Ext.connect
response = solr.find :q=>':'
response.ok? response.params response.docs response.docs.previous_page response.docs.next_page response.facets.each do |facet| puts facet.name facet.items.each do |item| puts "#{facet.name}::#{item.value} (#{item.hits})" end end
You can access values in the response hash using symbols or strings.
===Documents/Pagination If you wanna paginate the documents: <%= will_paginate response.docs.will_paginate %>
==The "Model" Module You can create your own "models" using RSolr::Ext::Model
class Book include RSolr::Ext::Model 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')
FAQs
Unknown package
We found that rsolr-ext demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 6 open source maintainers collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Bun 1.2 enhances its JavaScript runtime with 90% Node.js compatibility, built-in S3 and Postgres support, HTML Imports, and faster, cloud-first performance.
Security News
Biden's executive order pushes for AI-driven cybersecurity, software supply chain transparency, and stronger protections for federal and open source systems.
Security News
Fluent Assertions is facing backlash after dropping the Apache license for a commercial model, leaving users blindsided and questioning contributor rights.