I am using Apache Lucy to speed up a typeahead (autocomplete) field on a Web form. I am querying against nearly 800k records. I have a working setup but would like to limit my responses to terms that begin with the query string. Currently the query matchers either match the whole word or if I tokenize with /./
I can match the query against partials of whole words.
While going through the documentation I found Lucy::Docs::Cookbook::CustomQueryParser.
On that page under the heading Extending the query language, there was a reference to PrefixQuery
. This package does not exist in Lucy and I had to do some more searching. Eventually I found the PrefixQuery.pm code sample in lucy's git repository.
Note that this package references another non-existent package called Lucy::Search::Tally
. Removing the references to tally allowed me to get this example working, but it is far from a functional matcher. It doesn't handle multiple fields, no scoring, etc…
Does anyone know of a way to make Lucy do prefix matching without all this mucking about?
Found a solution in the Apache docs.
http://lucy.apache.org/docs/perl/Lucy/Docs/Cookbook/CustomQuery.html