Skip to content

Support for _routing field in SQL queries #339

Closed

Description

@newUserForTesting

Here is the relevant documentation for _routing field: https://www.elastic.co/guide/en/elasticsearch/reference/current/mapping-routing-field.html

This is extremely useful for optimizing query performance for large ElasticSearch cluster.
Requesting to please provide support for _routing field for SQL queries. We really appreciate your help!

Thanks!

Activity

  1. added
    enhancement
    on Dec 15, 2021
  2. self-assigned this
    on Jan 4, 2022
  3. penghuo commented on Jan 4, 2022

    @penghuo
    Collaborator

    Thanks for raising this!
    Currently, only field defined in index mapping is used as identifier in sql query. _routing is a metafield which is not defined in index mapping, so _routing could not been used as identifier in sql query.

    For example, following query will throw SemanticCheckException _routing is not defined.

    SELECT age, balance 
    FROM accounts 
    WHERE _routing = 'user1'
    

    I think one solution is to borrow pseudo columns concept to expose metadata field like _routing.

    @newUserForTesting Can you elaborate on your use case to provide us some insights?

  4. acarbonetto commented on Jun 30, 2022

    @acarbonetto
    Collaborator

    Proposal: couchbase offers META() as a way to retrieve metadata fields in their n1ql syntax https://docs.couchbase.com/server/current/n1ql/n1ql-language-reference/indexing-meta-info.html.

    We could consider coding something similar to SQL DSL that allows one to do:

    SELECT age, balance
    FROM accounts
    WHERE META()._routing = 'user1
    
  5. qianheng-aws commented on Apr 1, 2026

    @qianheng-aws
    Collaborator

    Resolved by #1805

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions