开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜