Reputation: 500
I've got a huge problem with Lucene (v3.5) search query. I'm trying to retrieve strings with hyphens using query containing hyphens and a wildcard sign(s), example: names in db: A4RER-88-22331 A4RER-22-32555 B3B8B-22-32555
query: A4RER-*
I've used WhitespaceAnalyzer (earlier StandardAnalyzer) but... the query is working for "A4RER*" but not "A4RER-*" :( I've googled a lot already, but still can't find a solution for this. Is there a simple way to force it to work?
thanks for any hint/help/snippet/anything
Upvotes: 4
Views: 1840
Reputation: 131
When using a WildcardQuery, replace hyphens with question marks. The question mark represents a single character.
Change this: "query: A4RER-*"
To this: "query: A4RER?*"
Upvotes: 1