SOLR - exact match phrase and logical search

We need help deploying SOLR to work with EXACT MATCH search capabilities.

In particular, we have a text field in the scheme, and we want to apply the search for exact matches with phrases and Boolean searches.

For instance:

User enters:

DIRECTOR AND (FINANCE OR CONTROLLER OR ACCOUNTANT)

..... But, unfortunately, the results return records with words like:

SCORE

CONTROLLING

Etc.

So, SOLR, in fact, is looking inside the word - which, of course, we do not want. (Yes, this will at least prioritize these results at the very END of the result set ... but nevertheless, our users want to get the exact matches that the Exact Match must fulfill.

We thought about changing the field to STRING instead of the TEXT type, but STRING does not work very well with phrases and logical searches.

+4
source share
2 answers

You need to disable the stems. If you look in the Solr schema.xml file, you will find field definitions and field types that control the type of processing that is performed in each field. Most likely, you just seized a default and did not configure it at all? I suggest you take some time to understand the options in this file; they are well documented in the solr quiz . But what you're asking is most likely the PorterStemFilter effect, so you can just comment on it and reload your data.

+2
source

You can create / duplicate this field using another data type.

therefore you will have.

schema.xml

<field name="title" type="text" indexed="true" stored="true"/> <field name="titleExactMatch" type="string" indexed="true" stored="true"/> <copyField source="title" dest="titleExactMatch"/> 

and then overwrite the "search weights" by overriding qf.

solrconfig.xml

 <requestHandler name="/select" class="solr.SearchHandler"> <!-- default values for query parameters can be specified, these will be overridden by parameters in the request --> <lst name="defaults"> <str name="df">titleExactMatch</str> <str name="echoParams">explicit</str> <int name="rows">10</int> <str name="defType">edismax</str> <str name="qf">titleExactMatch^2.2 title^0.4</str> <str name="sort">score desc, _version_ desc, title desc</str> </lst> 

Notes. I have not tested this config, but it should give you the results that you request, or at least in the order in which you need them.

+2
source

All Articles