Search code examples
elasticsearchsearchindexingblacklist

Specify an index blacklist when searching with ElasticSearch


An Elasticsearch query can cross multiple indexes with wild cards or multiple index specifications:

GET /index1,index2,indexwithwildcard*/_search

Is there some way to specify a list of indexes not to search, such that all indexes not in that list are searched?


Solution

  • Yes, by prepending - before the index name. Below, the search will exclude index3

    GET /index1,index2,indexwithwildcard*,-index3/_search