Home >Java >javaTutorial >Lucene practice--detailed explanation of keyword matching multiple fields

Lucene practice--detailed explanation of keyword matching multiple fields

零下一度
零下一度Original
2017-06-25 10:52:482311browse

Preface

When we enter keywords, we hope to support filtering multiple fields, so that the coverage of the search content will be larger.

The MultiFieldQueryParser class is mainly used to match multiple fields.

Single field search

QueryParser parser=new QueryParser("content",analyzer);
Query query =parser.parse(kw);

Multiple field search

String[] fields={"title","content"};
MultiFieldQueryParser parser=new MultiFieldQueryParser(fields,analyzer);

parser.parse(keywords,fields,analyzer);

The above is the detailed content of Lucene practice--detailed explanation of keyword matching multiple fields. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn