开发者

Lucene: Am I correctly parsing the strings ? Terms or Phrases?

开发者 https://www.devze.com 2023-02-18 08:51 出处:网络
I\'m new to Lucene. If I use description = new TermQuery(new Term(\"description\", \"my string\")); I ask Lucene to consider \"my string\" as unique word, right ?

I'm new to Lucene. If I use

description = new TermQuery(new Term("description", "my string"));

I ask Lucene to consider "my string" as unique word, right ?

I actually need to consider each word, should I use PhraseQuery instead ? Or i开发者_运维问答s it correct ?

thanks


Lucene Term Consructor says

Term: public Term(String fld,String txt)

Constructs a Term with the given field and text.

It means the field shall be description and "my string" would be content of the term.

You are just constructing a term, it doesnt say anything about the search results(Uniqueness or whatever)

If you need to consider each word,use a Booleanquery and add the required conditions there

0

精彩评论

暂无评论...
验证码 换一张
取 消