请大家帮我看个lucene的问题
一个查询问题郁闷好长时间了
//建立索引
IndexWriter iw = new IndexWriter("index", new StandardAnalyzer(), true);
Document doc = new Document();
doc.add(new Field("title", "Lucene创建索引示例", Field.Store.YES, Field.Index.TOKENIZED));
doc.add(new Field("author", "chenlb", Field.Store.YES, Field.Index.NO));
doc.add(new Field("date", "2008-03-08", Field.Store.YES, Field.Index.NO));
doc.add(new Field("content", "Lucene索引的内容在这里,这些内容不被存储.", Field.Store.YES, Field.Index.TOKENIZED);
iw.addDocument(doc);
//搜索1(可以查到)
IndexSearcher searcher = new IndexSearcher("index");
QueryParser parser = new QueryParser("content", new StandardAnalyzer());
Query q = parser.parse("索引");
Hits hits = searcher.search(q);
//搜索2
IndexSearcher searcher = new IndexSearcher("index");
BooleanQuery query = new BooleanQuery();
//查不到
query.add(new TermQuery(new Term("content","索引")),BooleanClause.Occur.MUST);
//查的到
query.add(new TermQuery(new Term("content","引")),BooleanClause.Occur.MUST);
query.add(new TermQuery(new Term("content","索")),BooleanClause.Occur.MUST);
Hits hits = searcher.search(query);
请问下为什么query.add(new TermQuery(new Term("content","索引")),BooleanClause.Occur.MUST);这样查的时候查不到记录
当把
doc.add(new Field("content", content, Field.Store.YES, Field.Index.TOKENIZED);//分词
改为
doc.add(new Field("content", content, Field.Store.YES, Field.Index.UN_TOKENIZED));//不分词
的时候我怎么都查不到记录我已经晕了请大家帮帮忙