Reputation: 696
I'm using lucene.net (2.3.2 ) and a ported version of the compatible WordDelimiterFilter, but when I perform wildcard searches with words with hyphens they don't work.
An example is the word "CL-276-0001", when I search for "cl" / "cl-276" / "cl-276-0001" I find the record no problem (which is what I was initially trying to solve), but now when I search for "cl-276*", or "cl-276-0*" it no longer works. "cl*" is unaffected, which leads me to believe it might be doing something with the query parser not adding the wildcard back onto whatever was called.
Any help to solve / understand this would be appreciated.
Edit: I looked at the query produced by the query parser. It is exactly what is typed, I'm guessing this means that the search doesn't work because it looks for exactly what the user typed as a prefix. Now I'm thinking I shouldn't alter this behaviour.
Second Edit: Someone asked what the analyzer looks like:
public override TokenStream TokenStream(string fieldName, TextReader reader)
{
TokenStream result = new WhitespaceTokenizer(reader);
result = new WordDelimiterFilter(result,1, 1, 1 , 1, 1 );
result = new StandardFilter(result);
result = new LowerCaseFilter(result);
result = new StopFilter(result, LoadStopWords());
return result;
}
Upvotes: 0
Views: 644
Reputation: 116178
CL-276-0001
is splitted into tokens [cl] [276] and [0001] by your analyzer and those tokens are stored in the index.
On the other and wildcard searches do not use analyzers only lowercase the search critaria. Since your search critarion cl-276
(or cl-276-0
) does not exist in the index you don't get any result.
One solution for this can be building a TermQuery(casing is important) instead of using QueryParser.
Upvotes: 1