我尝试使用短语查询搜索多个单词和特殊字符,例如“工程与建筑”,并将其添加到布尔查询中,但没有得到任何结果。我索引查询的方式是
doc.Add(new Field("Industry","Engineering & Construction", Field.Store.YES, Field.Index.ANALYZED,Field.TermVector.WITH_POSITIONS_OFFSETS));
对于搜索:
var booleanQuery = new BooleanQuery();
PhraseQuery phrasequery = new PhraseQuery();
phrasequery.Add(new Term("Industry","Engineering & Construction"));
booleanQuery.Add(phraseQuery, BooleanClause.Occur.MUST);
booleanQuery 包含 {+Industry:"Engineering & Construction"} 即使它没有得到想要的结果。