在 Lucene.net 搜索中使用特殊字符处理通配符搜索



如何执行通配符搜索 Lucene 中包含特殊字符的单词。 例如,如果我像"91*"一样搜索,我有一个像"91-95483534"这样的词,如果我像"91-95483534"一样搜索也可以正常工作。 但我的塞纳里奥是搜索"91-9548*"。 如果我像这样表演"91-9548*"。 我没有输出。 我错过了什么吗? 我的实际代码如下:

MultiFieldQueryParser queryParser = new MultiFieldQueryParser(new string[] {"column1","column2"}, new StandardAnalyzer());
queryParser.SetAllowLeadingWildcard(true);
Query query = queryParser.Parse(QueryParser.Escape(strKeyWord) + "*");

当你使用StandardAnalyzer时,这会把你的单词索引为91,如果你在索引时使用INDEX_ANALYZED,95483534。如果要搜索为 91-9548* ,请在索引具有"91-95483534"作为术语的指定字段时使用INDEX_NOT_ANALYZED

http://lucene.apache.org/core/old_versioned_docs/versions/3_0_3/api/core/org/apache/lucene/document/Field.Index.html

最新更新