Lucene TermQuery and QueryParser

后端 未结 1 811
不知归路
不知归路 2021-01-16 19:11

I have 2 lucene queries:

1)

Term term = new Term(Properties.LUCENE_APPARTMENT_ADDRESS,address);
Query termQuery = new TermQuery(term);
TopDocs topDo         


        
相关标签:
1条回答
  • 2021-01-16 19:29

    When you use QueryParser, it uses analyzer which does the same sequence of actions as when during the indexing (tokenization, lowercasing, stopwords, etc.).

    When you use raw TermQuery, you need to do all these steps yourself.

    I guess your analyzer does something special about Properties.LUCENE_APPARTMENT_ADDRESS and you are not when passing the address to TermQuery hence the search results discrepancy.

    0 讨论(0)
提交回复
热议问题