Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Lucene.Net TermQuery wildcard search

I have a lucene index I am trying to do a wildcard search. In index i have a character like '234Test2343' I am trying to do the search like %Test%..

My lucene syntax looks like

string catalogNumber="test";
Term searchTerm = new Term("FIELD", "*"+catalogNumber+"*");
Query query = new TermQuery(searchTerm);

I don't get the results back. Any thoughts?

Thanks

like image 470
bkhanal Avatar asked Oct 18 '09 03:10

bkhanal


1 Answers

You can use a WildCardQuery. A TermQuery looks for the literal asterisk, rather than a wild card. Please note that a WildCardQuery's performance is usually very slow, probably more so when using two wild cards as you do.

like image 154
Yuval F Avatar answered Oct 09 '22 12:10

Yuval F