Lucene.Net TermQuery Wildcard Search

I have a lucene index. I am trying to do a pattern search. In the index, I have a character like '234Test2343' I'm trying to search, for example% Test%.

My lucene syntax looks like

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

I will not return the results. Any thoughts?

thanks

+5
source share
1 answer

You can use WildCardQuery . TermQuery is looking for a letter asterisk, not a wild card. Please note that the performance of WildCardQuery is usually very slow, perhaps more so when you use two wild cards, just like you.

+7
source

All Articles