Question

I'm using Sunspot Solr on Rails for search.

In my class definition I have something like this (simplified from my real one):

searchable do
  text :name
  integer :count
  boolean :priority
end

Is there any way for me to access the integer and boolean field for their values directly in the hit results from a search?

I see there is the option to set up attribute fields with stored => true, which makes them available to the hit objects. However, the integer and boolean fields are clearly already stored as-is somewhere, as I'm capable of sorting and filtering them, just not accessing them through the hit object's stored method, so is there any way I can get them out for display?

If the answer to this is no, what exactly is stored => true doing when passed to an integer or boolean field?

I have a fairly large index on Websolr, and reindexing over this with stored => true would be a bit prohibitive.

Was it helpful?

Solution

Common field options

indexed=true|false
True if this field should be "indexed". If (and only if) a field is indexed, then it is searchable, sortable, and facetable.

stored=true|false
True if the value of the field should be retrievable during a search.

Indexed and Stored data is maintained differently. Indexed data is used internally by Solr for its operations.
If you want the data to be display you have to index the data with stored attribute true.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top