Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Problem with parent id containing commas when talking to an index alias #4202

Closed
hkorte opened this issue Nov 19, 2013 · 3 comments
Closed
Assignees

Comments

@hkorte
Copy link
Contributor

hkorte commented Nov 19, 2013

Hi,

I ran into problems trying to index a child document whose parent id contains commas. This only occurs using an index alias, with the index name it works. This is the resulting exception in 0.90.7:

ElasticSearchIllegalArgumentException: index/alias [parentid-testalias] provided with routing value [abc,2] that resolved to several routing values, rejecting operation
    at org.elasticsearch.cluster.metadata.MetaData.resolveIndexRouting(MetaData.java:338)
    at org.elasticsearch.action.index.IndexRequest.process(IndexRequest.java:557)
    ...

Here is some code to reproduce the problem:

Client client = new TransportClient().addTransportAddress(new InetSocketTransportAddress("localhost", 9300));

String indexName = "parentid-test";
String indexAlias = "parentid-testalias";
if (client.admin().indices().exists(new IndicesExistsRequest(indexName)).actionGet().isExists()) {
    client.admin().indices().delete(new DeleteIndexRequest(indexName)).actionGet();
}
CreateIndexRequest createIndexRequest = new CreateIndexRequest(indexName);
createIndexRequest.mapping("chld", "{\"chld\":{\"_parent\":{\"type\":\"prnt\"}}}");
client.admin().indices().create(createIndexRequest).actionGet();
client.admin().indices().prepareAliases().addAlias(indexName, indexAlias).execute().actionGet();

client.prepareIndex(indexName, "prnt", "abc,1").setSource("{\"text\":\"parent abc,1\"}").execute().actionGet();
client.prepareIndex(indexName, "chld", "def,1").setParent("abc,1").setSource("{\"text\":\"child def,1\"}").execute().actionGet();

client.prepareIndex(indexAlias, "prnt", "abc,2").setSource("{\"text\":\"parent abc,2\"}").execute().actionGet();
// this causes the exception - indexAlias and comma in parent id
client.prepareIndex(indexAlias, "chld", "def,2").setParent("abc,2").setSource("{\"text\":\"child def,2\"}").execute().actionGet();

client.close();

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html tells me that this is intended behavior: "...search routing may contain several values separated by comma. Index routing can contain only a single value."

So, if this is how it should be, then I would suggest to add some documentation on invalid characters in IDs, as I didn't find anything regarding this. Any suggestions?

@martijnvg
Copy link
Member

@hkorte I think this check that throws an error is only supposed to happen if you have a routing specified in the alias it self, not when someone is specifying it via routing or parent id. I think we can fix this, by only running this check if routing is resolved via the alias.

@martijnvg
Copy link
Member

But having a comma in the routing is tricky if it used at search time, maybe this should just be not allow a comma in the routing.

@clintongormley clintongormley self-assigned this Jul 4, 2014
@clintongormley
Copy link

Closing in favour of #6736

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants