SOLR Advanced Nine: SOLR searches for numbers and single characters

Source: Internet
Author: User
Tags solr

SOLR is equipped with a word breaker, but the word breaker has a filter with uppercase converted to lowercase, and the number is filtered. Like 123 Chinese ABC. 123 will be filtered out, so only check 1|12|123 will fail.

"SOLR numeric characters can not search for a problem" this blog post is more detailed, I am studying this article.

According to the account to search, when the account in the database is an integer variable, import into SOLR, configure a single number of filter field, is not the search for any information, for some reason, there is time to study schema.xml this configuration file first.

In schema.xml This configuration file, add the field type:

<fieldtype name= "Text_inclunum" class= "SOLR. TextField "positionincrementgap=" ><analyzer type= "index" ><tokenizer class= "SOLR. Whitespacetokenizerfactory "/><filter class=" SOLR. Edgengramfilterfactory "mingramsize=" 1 "maxgramsize=" "side=" front "/></analyzer><analyzer type=" Query "><tokenizer class=" SOLR. Whitespacetokenizerfactory "/><filter class=" SOLR. Edgengramfilterfactory "mingramsize=" 1 "maxgramsize=" side= "front"/></analyzer></fieldtype>

"SOLR. Edgengramfilterfactory "mingramsize=" 1 "maxgramsize=" 50 "This is a word from left to right.

Let's use this field type for our fields:

In the analysis to do a bit of analysis, see can cut:

No problem! Then search inside the search:

No problem, the most qualified in the front, followed by the second row in the back.

The rest of the matter is simple, follow the previous tutorial, change the configuration parameters, enter two characters to trigger:

The result of the final rendering is:

The front is the most consistent:

SOLR Advanced Nine: SOLR searches for numbers and single characters

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.