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

Lucene practice--detailed explanation of keyword matching multiple fields

零下一度
Release: 2017-06-25 10:52:48
Original
2317 people have browsed it

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);
Copy after login
Query query =parser.parse(kw);
Copy after login

Multiple field search

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

parser.parse(keywords,fields,analyzer);
Copy after login

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!

source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template