Search (autocomplete) suggestions on multi valued fields like tags with filters

I have an use case where I have bunch of images and i have multiple tags associated with each image. I have few attributes that are associated with each image and I would like to filter the suggestions based on few of those attributes. There could be more than one tags associated with each image.

id - tags - filter_a - filter_b
image1 - "tag1", "tag2", "tag3" - filter_a_val_1 - filter_b_val_1
image2 - "tag4", "tag5", "tag1" - filter_a_val_2 - filter_b_val_2
image3 - "tag2", "tag4", "tag1" - filter_a_val_1 - filter_b_val_3

Here are some questions

  1. How to make suggestions work with multi-valued fields. I can split them into multiple documents, but it makes an update to these multi-valued fields hard (initially 1 doc has N tags, then 1 doc has
  2. How do I handle duplicate tags across documents? I can do aggregation, but if we have a lot of duplicate tags then we have a risk of missing a lot of important suggestions from the shard response itself.

I am curious to hear from folks who were able to build autocomplete successfully on multi-valued fields and how did you handle the above two issues.

@jimczi I read your suggestion to create a separate index for tags and make them unique https://github.com/elastic/elasticsearch/issues/22912#issuecomment-328575611

But it makes the index stale and we cannot delete the tags. Do you have any suggestions on how to handle deletes? We can reindex all the documents, but that would be a very expensive operation for big indices.

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