Searching through an alias with filter is very slow in Elasticsearch Searching through an alias with filter is very slow in Elasticsearch elasticsearch elasticsearch

Searching through an alias with filter is very slow in Elasticsearch


Matching each document with a 4MB list of uids is definetly not the way to go. Try to imagine how many CPU cycles it requires. 8s is quite fast.

I would duplicate the subset of data in another index.

If you need to immediately reflect changes, you will have to manage the subset index by hand :

  • when you delete a uuid from the list, you delete the corresponding documents
  • when you add a uuid, you copy the corresponding documents (reindex api with a query is your friend)
  • when you insert a document, you have to check if the document should be added in subset index too
  • when you delete a document, delete it in both indicesForce the document id so they are the same in both indices. Beware of refresh time if you store the uuid list in elasticsearch index.

If updating the subset with new uuid is not time critical, you can just run the reindex every day or every hour.