lucene搜索输入一个关键字,如何匹配多个索引field
索引代码如下
Document doc = new Document();
doc.add(new Field("contents", rs.getString("title"), Field.Store.YES,
Field.Index.ANALYZED));
doc.add(new Field("roomid", rs.getString("roomid"), Field.Store.YES,
Field.Index.ANALYZED));
doc.add(new Field("address", rs.getString("address"), Field.Store.YES,
Field.Index.ANALYZED));
doc.add(new Field("cell", rs.getString("cell"), Field.Store.YES,
Field.Index.ANALYZED));
BooleanQuery query = new BooleanQuery();
query.add(new QueryParser(Version.LUCENE_43, "contents", new IKAnalyzer(true)).parse(s), BooleanClause.Occur.SHOULD);
query.add(new QueryParser(Version.LUCENE_43, "roomid", new IKAnalyzer(true)).parse(s), BooleanClause.Occur.SHOULD);
query.add(new QueryParser(Version.LUCENE_43, "address", new IKAnalyzer(true)).parse(s), BooleanClause.Occur.SHOULD);
query.add(new QueryParser(Version.LUCENE_43, "cell", new IKAnalyzer(true)).parse(s), BooleanClause.Occur.SHOULD);