Help needed with completion suggestor

Refer to your comment -
I need to do exactly that, have ES return suggestions from a set of tags, instead of returning documents.
Can you share how a separate index with completion field can be used?

The idea is a to have a separate index where its documents consists only of the tags, thus only the tags are returned, even though internally it's all still documents. There is no magic, just an additional index, that is decoupled from your other data (and thus also needs manual updating)

1 Like

@spinscale Thanks for the points.
Actually there are a couple of things that caught my attention and was wondering if you can help me understand

  1. "Just create a tags index, set the _id of the document to be the tag name and create one document per tag with a completion field " - Why set _id to tag name? Im guessing it is to ensure non-duplication of tags while indexing using op_type=create. Is it?
  2. "In fact I am not even sure you need a completion field for that if your index is separated, just use the prefix and fuzzy rewrite options on a keyword field to match your needs." - What is this about? Also, if we do not have a completion field we lose the optimization ES provides for auto suggest feature right?
  3. The last question I had was - what if I wanted to capture user search strings and use them as auto suggest tags. I can simply add search strings as well to this separate index. This part is ok. But, I would want more frequently searched terms/tags to be returned in preference to others. Im guessing the "weight" parameter for the tag can help. But how do I dynamically update weight for an existing tag? This one is puzzling me a lot !
  1. to ensure that you always return all the available suggestions
  2. That was just an alternative idea so solve the issue. Wont be as fast as suggestions though.
  3. You need a feedback loop to implement this, know which queries are used a lot, and those get a higher weight, this requires some more on your side as there is no mechanism inside of ES to do that. But this would be ideally the way to go with suggestions (there is a reason why searching for an iphone returns the latest iphone on ecommerce sites as a first hit compared to anything else, cause of such an implemented feedback loop - which might be based on searches, but very likely is also based on sales data and thus a bit more complex).

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.