开发者

How can I create PhraseQuery for multiple fields with custom Analyzer?

开发者 https://www.devze.com 2023-03-11 21:25 出处:网络
I would like to parse user request \"Hello world!\" by my cust开发者_运维百科om analyzer and search throw \"title\", \"description\" fields by using PhraseQuery

I would like to parse user request "Hello world!" by my cust开发者_运维百科om analyzer and search throw "title", "description" fields by using PhraseQuery

I found crazy solution of my problem but it looks not optimized


Try MultiFieldQueryParser. You can specify list of fields for which the query is to be created.


If you are using own custom analyzer and using that analyzer to parse query according to your need you must see jFlex(Use to change lucene grammar).

Note: Same custom analyzer need to be used on both side while creating index and while searching query.

You need to use SpanNearQuery while searching for phrase like "Hello world!"

SpanNearQuery spanNear = new SpanNearQuery(span, 0, true);

0

精彩评论

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

关注公众号