0

如何在 lucene 中执行通配符搜索包含特殊字符的单词。例如,我有一个像“ 91-95483534 ”这样的词,如果我像“ 91* ”这样搜索它可以工作,如果我像“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) + "*");
4

1 回答 1

1

As you used StandardAnalyzer, that indexed your word as 91 and 95483534 if you used INDEX_ANALYZED when you index.... if you want to search as 91-9548* , use INDEX_NOT_ANALYZED when you index that specified field which have "91-95483534" as terms

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

于 2012-05-24T07:10:32.310 回答