Sunspot Solr search parameter "c" does not work with strings

I am developing a Ruby on Rails application using Sunspot Solr as an indexer. The thing is, I am trying to use a search parameter with:, using strings and does not seem to work. If I pass int, it works fine. Does anyone know how to do this with strings (if possible)?

An example of the search I want to do:

@search = Sunspot.search(Record) do fulltext params[:query] with :checked, "Checked" end 

: checked is an attribute of the Record table, and it checks to see if the record is checked, so it cannot be edited.

PD: I do it this way because MySQL does not accept booleans.

+4
source share
1 answer

It revealed!

It turns out that the strings are a bit more delicate, so you should use:

with (: checked) .equal_to ("any_value")

For more information see

https://github.com/sunspot/sunspot/wiki/Scoping-by-attribute-fields

+4
source

All Articles