Venkat Narayan
Venkat Narayan

Reputation: 31

handling wildcard search with Special character in Lucene.net search

how do i perform wildcard search a word in lucene that contain special character. for example i have a word like "91-95483534" if i search like "91*" it works and if i search like "91-95483534" also works fine. but my senario is that to search "91-9548*". if i perform like this "91-9548*". i got no output. am i missing anything. my actual code is given below:

MultiFieldQueryParser queryParser = new MultiFieldQueryParser(new string[] {"column1","column2"}, new StandardAnalyzer());

queryParser.SetAllowLeadingWildcard(true);

Query query = queryParser.Parse(QueryParser.Escape(strKeyWord) + "*");

Upvotes: 0

Views: 1313

Answers (1)

rrsk
rrsk

Reputation: 124

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

Upvotes: 1

Related Questions