Hi,
I hacked up a little plugin, which uses the Lucene FSTSuggester for
providing suggestions - and only suggestions, no query result data at
all. Basic functionality is like this:
curl -X POST localhost:9200/products/product/_suggest?pretty=1 -d
'{ "field": "ProductName.suggest", term: "product 1" }'
{
"suggestions" : [ "product 1", "product 10", "product 100", "product
1000", "product 101" ],
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}
You can add a size parameter for setting the count of returned
products (default is 10).
You can add a similarity parameter for catching typos (is not set by
default) like this:
curl -X POST localhost:9200/products/product/_suggest?pretty=1 -d
'{ "field": "ProductName.suggest", term: "proudct", similarity: 0.7 }'
{
"suggestions" : [ "product" ],
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
}
}
That's it out of a functionality point of view. It took me some time
to understand how serialization and deserialization of the requests
(and the sharded requests) work, and apart from that I am not a Lucene
expert. So, if you find something to improve, just start bugging me
(there is already quite a long list in the README, what I should do
next).
The project is available at https://github.com/spinscale/elasticsearch-suggest-plugin
and includes a README which should help you to setup suggestion and
the correct index fields. If you come up with better solutions (you
for sure will), drop me a mail. I am not yet using it in production,
this is the reason why I put the big warnings in the readme
Regards, Alexander