Solr: verbose synonyms

I am developing a set of synonyms where you can find several verbose expressions, for example:

black berry => blackberry

At the analysis stage and using the /admin/analysis.jsp tools, I see that the results are correct.

A query such as "quiero una black berry" returns the following sequence:

. org.apache.solr.analysis.StandardTokenizerFactory {luceneMatchVersion = LUCENE_36}:

position 1 2 3 4 term text quiero una black berry startOffset 0 7 11 17 endOffset 6 10 16 22 type <ALPHANUM> <ALPHANUM> <ALPHANUM> <ALPHANUM> 

org.apache.solr.analysis.SynonymFilterFactory {synonyms = lang / synonyms_es.txt, expand = false, ignoreCase = true, luceneMatchVersion = LUCENE_36}:

 position 1 2 3 term text quiero una blackberry type <ALPHANUM> <ALPHANUM> SYNONYM startOffset 0 7 11 endOffset 6 10 22 

However, if I try this sentence in a "real" request, the request handler (evolution of the edismax handler), the tokens "black" and "berry" were not replaced by "blackberry".

I saw here that you can solve this situation by changing the FieldQParser plugin.

In any case, since such a post was made almost 3 years ago, I would like to know if there is a way to solve this problem inside Solr, avoiding the need to extend some plugin.

Thanks.

+2
source share
2 answers

In Solr-6.5.0, you can enable multi-mode synonyms for request time by setting the parameter below

From the documentation

Sow parameter

Separate by spaces: if set to false, seed-separated sequences will be provided for text analysis in one shot, providing the proper function of analysis filters that work on terminal sequences, for example. verbose synonyms and roof tiles. Default values ​​to true: text analysis is called separately for each person, a space, separated by a space.

[synonym.txt]

 black berry => blackberry 

[Example]

 q=black berry &sow=false &debug=query 

[debugging response]

 <lst name="debug"> <str name="rawquerystring">black berry</str> <str name="querystring">black berry</str> <str name="parsedquery">_text_:blackberry</str> <str name="parsedquery_toString">_text_:blackberry</str> <str name="QParser">LuceneQParser</str> </lst> 

Now you can see the debugging answer that I was looking for a black berry , but the factory synonym filter matches the word that I mentioned in the synonym.txt file.

0
source

Source: https://habr.com/ru/post/957906/


All Articles