Index aliases vs _search

Hi,

I will try to explain the situation first, if that is not enough I will try
to prepare full curl example.
I created an index alias named 1 pointing to index named 'users' with
routing (routing=1) and filter (filtering by term: user=1). Then I indexed
new data using created alias (1). Data is inserted in correct shard, so the
routing value was used properly. I can get the document by _id using
created alias (1) but I can not _search via this alias.

  • curl -XPOST localhost:9200/users/_search - finds indexed documents
  • curl -XPOST localhost:9200/1/_search - does not.

What is the most important, I removed alias '1' and added it again.
Now curl -XPOST localhost:9200/1/_search works fine and finds all the
created documents.

Is this description enough to investigate the problem or should I try to
recreate it step by step using curl queries ?

Thanks for help.
Best regards.
Marcin Dojwa.

--

OK, I recreated full curl example. In this example I used 1 node only. It
is available here: Index aliases vs search · GitHub

Could you help me with this ? Unfortunately this behavior makes index
aliases useless for me and this is necessary to make "User" data flow
working fine :slight_smile:

Thank you for help.
Best regards.
Marcin Dojwa.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

Hi,

I will try to explain the situation first, if that is not enough I will
try to prepare full curl example.
I created an index alias named 1 pointing to index named 'users' with
routing (routing=1) and filter (filtering by term: user=1). Then I indexed
new data using created alias (1). Data is inserted in correct shard, so the
routing value was used properly. I can get the document by _id using
created alias (1) but I can not _search via this alias.

  • curl -XPOST localhost:9200/users/_search - finds indexed documents
  • curl -XPOST localhost:9200/1/_search - does not.

What is the most important, I removed alias '1' and added it again.
Now curl -XPOST localhost:9200/1/_search works fine and finds all the
created documents.

Is this description enough to investigate the problem or should I try to
recreate it step by step using curl queries ?

Thanks for help.
Best regards.
Marcin Dojwa.

--

I forgot to mention that I use ES 0.19.8.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

OK, I recreated full curl example. In this example I used 1 node only. It
is available here: Index aliases vs search · GitHub

Could you help me with this ? Unfortunately this behavior makes index
aliases useless for me and this is necessary to make "User" data flow
working fine :slight_smile:

Thank you for help.
Best regards.
Marcin Dojwa.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

Hi,

I will try to explain the situation first, if that is not enough I will
try to prepare full curl example.
I created an index alias named 1 pointing to index named 'users' with
routing (routing=1) and filter (filtering by term: user=1). Then I indexed
new data using created alias (1). Data is inserted in correct shard, so the
routing value was used properly. I can get the document by _id using
created alias (1) but I can not _search via this alias.

  • curl -XPOST localhost:9200/users/_search - finds indexed documents
  • curl -XPOST localhost:9200/1/_search - does not.

What is the most important, I removed alias '1' and added it again.
Now curl -XPOST localhost:9200/1/_search works fine and finds all the
created documents.

Is this description enough to investigate the problem or should I try to
recreate it step by step using curl queries ?

Thanks for help.
Best regards.
Marcin Dojwa.

--

Hi,

I've just noticed that if I add any document to index 'test' before
creating the alias it works fine. This case does not work for aliases
created when index is empty only. Eg. if I put

curl -XPOST 'http://localhost:9200/test/documents/doc1' -d
'{"user":3,"data":"sample data"}'

right after creating index 'test', the rest curl queries works fine
(creating alias '1' for "user":1, adding documents using alias '1' with
"user":1 and searching documents using alias '1').

Please let me know if this always behaves properly if any document exists
in the index first. I need to know if I can make such an assumption in my
project.

Thank you for help.

Best regards.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

I forgot to mention that I use ES 0.19.8.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

OK, I recreated full curl example. In this example I used 1 node only. It
is available here: Index aliases vs search · GitHub

Could you help me with this ? Unfortunately this behavior makes index
aliases useless for me and this is necessary to make "User" data flow
working fine :slight_smile:

Thank you for help.
Best regards.
Marcin Dojwa.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

Hi,

I will try to explain the situation first, if that is not enough I will
try to prepare full curl example.
I created an index alias named 1 pointing to index named 'users' with
routing (routing=1) and filter (filtering by term: user=1). Then I indexed
new data using created alias (1). Data is inserted in correct shard, so the
routing value was used properly. I can get the document by _id using
created alias (1) but I can not _search via this alias.

  • curl -XPOST localhost:9200/users/_search - finds indexed documents
  • curl -XPOST localhost:9200/1/_search - does not.

What is the most important, I removed alias '1' and added it again.
Now curl -XPOST localhost:9200/1/_search works fine and finds all the
created documents.

Is this description enough to investigate the problem or should I try to
recreate it step by step using curl queries ?

Thanks for help.
Best regards.
Marcin Dojwa.

--

Shay, could you take a look at this ? Thank you.

Best regards.
Marcin Dojwa.

2012/8/13 Marcin Dojwa m.dojwa@livechatinc.com

Hi,

I've just noticed that if I add any document to index 'test' before
creating the alias it works fine. This case does not work for aliases
created when index is empty only. Eg. if I put

curl -XPOST 'http://localhost:9200/test/documents/doc1' -d
'{"user":3,"data":"sample data"}'

right after creating index 'test', the rest curl queries works fine
(creating alias '1' for "user":1, adding documents using alias '1' with
"user":1 and searching documents using alias '1').

Please let me know if this always behaves properly if any document exists
in the index first. I need to know if I can make such an assumption in my
project.

Thank you for help.

Best regards.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

I forgot to mention that I use ES 0.19.8.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

OK, I recreated full curl example. In this example I used 1 node only.
It is available here: Index aliases vs search · GitHub

Could you help me with this ? Unfortunately this behavior makes index
aliases useless for me and this is necessary to make "User" data flow
working fine :slight_smile:

Thank you for help.
Best regards.
Marcin Dojwa.

2012/8/11 Marcin Dojwa m.dojwa@livechatinc.com

Hi,

I will try to explain the situation first, if that is not enough I will
try to prepare full curl example.
I created an index alias named 1 pointing to index named 'users' with
routing (routing=1) and filter (filtering by term: user=1). Then I indexed
new data using created alias (1). Data is inserted in correct shard, so the
routing value was used properly. I can get the document by _id using
created alias (1) but I can not _search via this alias.

  • curl -XPOST localhost:9200/users/_search - finds indexed documents
  • curl -XPOST localhost:9200/1/_search - does not.

What is the most important, I removed alias '1' and added it again.
Now curl -XPOST localhost:9200/1/_search works fine and finds all the
created documents.

Is this description enough to investigate the problem or should I try
to recreate it step by step using curl queries ?

Thanks for help.
Best regards.
Marcin Dojwa.

--

I've encountered this issue myself and this thread while trying to figure this thing out.

I've found that in order to make the alias work on an empty index you need to set the mapping for the routing field (in your case, "user").

Hope this helps to anyone,
Yarin.