Exclude indexes in java search API

(Alex Davidovich) #1


I am using elasticsearch 5.4.1.
I create queries using JAVA API and until now we had 5 indexes.
I always searched all 5 of the indexes and in order to achieve this, I didn't send index names with the search request.
Now we are going to add a 6 index and now there are 2 usecases:

  1. search the 6th index alone - just send its name with the search request.
  2. search all indexes excluding the 6th.

I can't give the 5 indexes names hardcoded in the request since they are deleted and created dynamically by the system (with random names).
So I need to maintain a list of indices in memory and modify this list when it changes in ES.
I don't like this so much and wanted to have an API in JAVA that can tell ES to search all indexes except the 6th (that has a constant name).
Can it be done?


(David Pilato) #2

I'd use an index template which sets an alias for the new index automatically. Then you just have to query the alias.

(Alex Davidovich) #3

Thank you

(system) #4

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