Sunspot / Solr requests ending with AND / OR / NOT booleans result in an error

I noticed that queries ending with logical operators, such as the AND / OR / NOT ("this AND") example, will result in an error. Now, what would be the best way to handle this? Just crop or avoid all queries ending with one of them? Please note that this also happens for queries starting with one of these words. And sometimes, real names end with words like Oregon OR.

+3
source share
1 answer

I believe that avoiding any AND / OR / NOT instances in your query that are not intended for logical logic would be your best bet:

Article.search do
  fulltext 'Oregon OR'
end
# => Throws error along the lines of this:
# RSolr::RequestError: Solr Response: orgapachelucenequeryParserParseException_Cannot_parse_Oregon_OR_Encountered_EOF_at_line_1_column_9_Was_expecting_one_of_____NOT______________________________QUOTED______TERM______PREFIXTERM______WILDTERM__________________NUMBER______TERM____________


Article.search do
  fulltext 'Oregon \OR'
end
# => Returns results with "Oregon OR"

, AND/OR/NOT :

fulltext "Oregon \\OR"
+6

All Articles