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

automatically fill routing parameters based on querystring #2325

Closed
yuhanonescreen opened this issue Oct 13, 2012 · 1 comment
Closed

automatically fill routing parameters based on querystring #2325

yuhanonescreen opened this issue Oct 13, 2012 · 1 comment

Comments

@yuhanonescreen
Copy link

Currently field routing will route a record to a row during the indexing phase. However, when we are querying it, it expects the user to provide the routing= parameter, ignoring the field appearing in the query. if no routing parameter, the request will reach all shards.

Please improve the field routing feature to automatically detect the routing number from the query such that if the field value appeared in the query, automatically take that value as the routing key.

Example:

we have a index "videos" defined with routing on "account_id" field:
"videos": {
"_routing": {
"required": true,
"path": "account_id"
},
"properties": {
"account_id": {
"type": "integer",
"ignore_malformed": false
},
"text": {
"type": "string",
"analyzer": "simple"
},
...

The two queries given different performance (measured through apache bench):
- http://localhost:9200/videos/_search?q=account_id:1001560%20and%20text:vampire
- http://localhost:9200/videos/_search?q=account_id:1001560%20and%20text:vampire&routing=1001560

Make it such that if account_id field appears in query, it automatically assign it as routing (so that no need to update it at application level. )

Thank you.

request based on the discussion from the mailing list:

Hi Yuhan

The existing code consists various queries with account_id provided.
ex:
http://localhost:9200/videos/_search?q=account_id:123+AND+text:test

So, will elasticsearch smartly reach just 1 shard on this query? or
will it still reach all shards?

Ah right. Not sure, but I think the answer is probably no. It won't do
that automatically. You'll still need to provide the routing value.

Maybe it could be supported. Perhaps open an issue.

clint

@clintongormley
Copy link
Contributor

Hi @yuhanonescreen

The search request is routed to the shards that need to handle the request before the query is parsed. In fact, we're discussing removing support for the _routing path in #6730. On top of that, multi-index, multi-type queries with potentially many different analyzer configurations would make this automatic routing a nightmare to implement and debug.

If you know what field should be used for routing, why not extract it in your application and use it as a routing value to the query? Seems a lot simpler than trying to get it right within something as complex as the query dsl.

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

2 participants