Query after QueryParse: "The Republic of China" cannot be found, but "the People's Republic of China" can find

Source: Internet
Author: User

I guess there are a lot of people mixed up with this stuff, the problem is that QueryParse will query PhraseQuery with syntax for word splitting results, and the default slop for syntax query is 0 (for slop please refer to: http://www.blogjava.net/freeman1984/archive/2011/02/25/345116.html ).

Tears ran, always thought the index problem, Thanks luke: http://luke.codeplex.com/

The following is a help method for setting slop to 99 for decomposition query:

Private void SetSlop (Query q)
{
Var bQuery = q as BooleanQuery;
If (bQuery! = Null)
{
Foreach (var bq in bQuery. clses ())
{
Var query = bq as BooleanClause;
If (query! = Null)
{SetSlop (query. GetQuery ());}
}
Return;
}
Var pQuery = q as PhraseQuery;
If (pQuery! = Null)
{
PQuery. SetSlop (99 );
}
}

 

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.