Reputation: 4811
I am currently using the QueryParser method of searching, but I don't want to give the end user so much control.
So currently if they are searching for a work like this:
The*
I will just pass that into the QueryParser.parse() method.
Now in my UI I will have a input box that says "Starts With" and let them enter the text.
How would I create a search query that would then search based on the above? (I will have other input boxes for other things like min/max length etc.)
Upvotes: 0
Views: 27
Reputation: 94
PrefixQuery is what you are looking for -
new PrefixQuery(new Term("inputIndex","searchstring"));
This will return all documents indexed with field 'inputIndex' having value starting with "searchstring".
searcher.search(new PrefixQuery(new Term("inputIndex","searchstring")));
Upvotes: 2