Mo
Mo

Reputation:

Lucene.Net query with leading wildcard

Good afternoon,

I need to be able to search a Lucene.Net index with a wild card prefix; i.e. now when I search for the word "paint" "autopaint" does not come up, but I need it to.

I have seen mentioned "SetAllowLeadingWildcard" elsewhere in Stack Overflow, but I don't see that property - maybe because I'm using Lucene.NET?

Thanks, Mo

Upvotes: 2

Views: 1691

Answers (1)

adrianbanks
adrianbanks

Reputation: 82944

Which version of Lucene.Net are you using? The SetAllowLeadingWildcard property is on QueryParser in v2.1.

To be able to search for paint and get autopaint back as a result, you would have to search for *paint. Searching for paint would not return autopaint.

Take heed of the note in the comments on the property though:

Note that this can produce very slow queries on big indexes.

Upvotes: 3

Related Questions