SOLR extension dismaxqparser

Source: Internet
Author: User
Tags solr

Reproduced http://www.colorfuldays.org/program/solr/solr%E6%89%A9%E5%B1%95dismaxqparser/
 

Recently, my colleagues in the product gave me a question about the search. When users enter "queryparser Customization", they cannot find the search results, but the search "queryparser Customization" can find the correct results. This problem leads to a high failure rate in search. I started to solve the problem the day before yesterday. After two days of research, I finally customized queryparser to solve the problem. The solution to this problem is to customize the queryparser of SOLR. The following describes how to customize the queryparser of SOLR.

Our search engine uses the edismax type. Because some businesses need to use the features provided by edismax, they can only be customized on edismax.
Perform a word segmentation test. The word segmentation result of "queryparser Customization" is consistent with that of "queryparser Customization.
Open debugquery and compare "queryparser custom" with "queryparser custom" to output querystring.
"Queryparser Customization" is displayed as follows:
"Parsedquery": "+ (disjunctionmaxquery (goods_title: queryparser ))
Disjunctionmaxquery (goods_title: custom )))~ 2 )",

"Queryparser Customization" is as follows:
"Parsedquery": "+ disjunctionmaxquery (goods_title: \" queryparser custom \"))",

We can see from the above two results that although the word segmentation is correct, edismax's processing method is not as expected and can only be solved by modifying the source code.
Find the corresponding code extendeddismaxqparserplugin. java. After studying the process through debug, find out where to modify it.
After modifying the source code, compress the class into Lib. The deployment method is as follows:
1. Put the prepared package under $ {SOLR. Home}/lib to ensure that SOLR will be loaded to this jar at startup.
2. modify the configuration below solrconfig. xml:
Add a new queryparser:

<Queryparser name = "newdismax" class = "com. server. SOLR. newextendeddismaxqparserplugin"/>

Use the new queryparser:

 <requestHandler name="/browse" class="solr.SearchHandler">                               <lst name="defaults">                                                                    <str name="echoParams">explicit</str>                                                <str name="wt">json</str>                                                            <str name="json.ml">map</str>                                                                                                                                                    <str name="defType">newdismax</str>                                                  <str name="rows">20</str>                                                            <str name="mm">1</str> <lst> </requestHandler>

Note that the name in newextendeddismaxqparserplugin must be changed to newdismax. As follows:
Public static final string name = "newedismax ";

After SOLR is restarted, you can use the new queryparser. You can customize this class to meet other requirements.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.