I’d like to reproduce the following raw solr query with sunspot
q=exact_term_text:foo OR term_textv:foo* OR alternate_text:bar*
but I am not able to understand if and how this is possible, through the standard sunspot interface, since it seems that:
- the
fulltextmethod does not seem to accept multiple text/search_fields arguments - I wouldn’t know what argument to pass as the first one to
fulltext, as if I pass either"foo"or"bar"the results would not match - If I pass an empty argument I get a
q=*:* - the scope filters (e.g.
with(:term).starting_with('foo*')are (as the name implies) applied as filter queries, and thus take no part in scoring.
It seems possible to hand-compose the string (or possibly use adjust_solr_params) but that seems hackish. Is there a better solution?
In Sunspot 2.0.0, there is undocumented and unsupported behaviour that does work. The author himself suggests it shouldn’t and it probably won’t in future versions.
You can pass multiple fulltext calls into the search definition
This results in a solr query of (from the logs)
Matching substrings is covered in
https://github.com/sunspot/sunspot/wiki/Matching-substrings-in-fulltext-search
Changing the default operator (AND/OR) can be done by adding a option
minimum_match 1
as mentioned in http://blog.tonycode.com/archives/192