solrkeywordliteralsedismax

How do you force solr eDismax search to treat a reserved word as a literal?


One record in my solr data has a field with the value "NOT 123456". Since "NOT" is a reserved word for negativity, when I send a query with

defType=edismax&q=NOT 123456

all records excluding the one with the value "NOT 123456" are returned. How do I modify "NOT" to be treated as a literal, instead?


Solution

  • According to the Lucene Query Syntax, you have two options here:

    1. If you don't need to search for the reserved word in all UPPERCASE, you could just use the lowercase form. This will work, because reserved words trigger only when they are all uppercase.
    2. If you need the uppercase form, you should enhance the reserved word in your query with "double quotes", because reserved words trigger only, when they are surrounded by whitespace.