Indexing using main index while search using index aliases


(Samir N) #1

I am hoping to avoid insert to each individual index alias. Is there a way I can upload data to the main index while the data is queried via aliases created on the index. I am using the index template to define a template with aliases.

suppose -
main index: space, and have 2 index aliases: space-stars, space-planets
I would like to insert data using the main index
curl -XPOST localhost:9200/space/all -d ....
and then query using an alias (which should filter the data that matches the alias' filter pattern)
curl -XGET localhost:9200/space-stars/_search
curl -XGET localhost:9200/space-planets/_search

So far in my testing by inserting 8 records (4 records for each alias based on filter definition), I see random results. Sometimes I see the search (using the alias) return just 1 hit (most often the first inserted item) and other times nothing. If I query the "space" index directly, all 8 records are returned.

Thanks,
Samir


(David Pilato) #2

This should work fine. It's the best practice IMO:

Index using index name
Query using aliases

May be you did something wrong when defining your aliases?


(Samir N) #3

Thanks David. Upon your confirmation, I went with explicit removal of aliases before deleting the index, and then populate the index, and search the aliases. That seems to be working consistently now. Earlier I presumed that index deletion will fully clean up aliases but apparently not and it may have lead to inconsistent results when querying thru aliases.


(system) #4