How to perform a GetById from multiple indices


(Vins Yu) #1

Use Case:
I have two indices (archive and active). Now during search and retrieve, it should be able to perform the action on both indices. However, for update and create new documents, it should be able to execute the action on the active index only.

Currently, I created two aliases. alias1 points to both archive and active index while alias2 only points to active index.

During search, I'm able to search on both indices using alias1. However, when calling method

public GetRequestBuilder prepareGet(String index, String type, String id)

I'm getting an error:

Alias [alias1] has more than one indices associated with it 
[[achive, active]], can't execute a single index op]"

What's the best way to handle this situation? Clients and users performing getById does not know whether the content is in archive or active index. This is transparent to them.

Thanks,
/Vins


(Colin Goodheart-Smithe) #2

You could use the mget API to perform a get on both indices and then choose which response to use in your response to your user (which ever get succeeds presumably)


(Vins Yu) #3

Thanks Colin. I'll try this out.

Regard,
/Vins


(system) #4