spinscale / elasticsearch-suggest-plugin

Plugin for elasticsearch which uses the lucene FSTSuggester
203 stars 42 forks source link

Suggests for multiple fields #20

Closed dzhlobo closed 11 years ago

dzhlobo commented 11 years ago

Hi.

Is there any difficulties to add ability to suggest not only for one specific field?

For example it would be great to make queries like this:

cur -X GET localhost:9200/cars/car/__suggest?pretty=1 -d '{ "fields": ["name", "description"], "term": "au", "size": "10"  }'
spinscale commented 11 years ago

Hey, sorry for getting back that late...

In theory it is not, in practice I refrained from this, because it means I have to wait for requests to return inside of elasticsearch, where I think it might make sense to wait this on the client side.

Anything wrong with my assumption?

dzhlobo commented 11 years ago

I'm not well with internals of plugin. If it will take 2x time for suggestions for 2 fields I agree with you that it's not very good idea.

One reason I see one request for multiple fields can be a little bit faster than multiple requests is reducing time on http handshake (and probably equal initializing of the same objects). But it also adds some questions:

spinscale commented 11 years ago

Sorry, I was not clear here.

The main reason I do not want to put this into the main action, is that I need to wait in the REST action (or somewhere else in the code), until both requests have returned. As this requires for my code to be blocking somewhere, I would rather like to source this out to the requester.

Regarding your first question about the order: The order is always alphabetic, so it is pretty easy to sort this on the client side yourself.

About the size parameter: After sorting alphabetically reducing two requests into one is not a big deal then...

Does it make sense?

dzhlobo commented 11 years ago

Yes, I agree with you.

I think I can close this issue.