You should define another field in your schema.xml
that doesn't do any analysis on your data. The easiest way to do this in your case is probably doing the following:
<field name="exact_description" type="string" indexed="true" stored="false" multiValued="true" />
<copyField source="originalColumnName" dest="exact_description" docValues="true" />
Using the string
type will keep Solr from tokenizing or doing anything else to your data.
Then, when building your query, you can put something like the following before the rest of your query:
exact_description:"hello man"^100.0
Make sure you put a boost (the ^100.0
) of your choice on exact_description
, so exact matches will be forced to the top of your results.
When you create your new field, make sure you base it off of a field that hasn't had any analysis performed on it. For example, in my schema, I have a field called exact_match
, which is copied from the following:
<field name="match" type="string" indexed="false" stored="true" required="false" omitNorms="true" />
Now, I could have just used match
for exact matches in search since match
is just a string, but for spec reasons I had to create exact_match
like this:
<field name="exact_match" type="string" indexed="true" stored="false" multiValued="true" />
<copyField source="match" dest="exact_match" docValues="true" />