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

Query constructor issue with labels containing "__" #1636

Closed
sudheer82 opened this issue Nov 30, 2022 · 1 comment
Closed

Query constructor issue with labels containing "__" #1636

sudheer82 opened this issue Nov 30, 2022 · 1 comment

Comments

@sudheer82
Copy link

sudheer82 commented Nov 30, 2022

If the column name has any __, then the Query constructor is converting into .

from elasticsearch import Elasticsearch
from elasticsearch_dsl import Q, Search
Q(
    "range",
    some__field_name={
            "gte": "2022-10-01",
            "lte": "2022-11-30"
    },
),

Constructed resulting query is as follows. As you can see, its converting __ in field name to .

{
    "range": {
        "some.field_name": {
            "gte": "2022-10-01",
            "lte": "2022-11-30"
        }
    }
}

when changed to a hand crafted json, then it works

{
    "range": {
        "some__field_name": {
            "gte": "2022-10-01",
            "lte": "2022-11-30"
        }
    }
}

Let me know if there is a missing step or a known issue and if some work around exists.

@Y-Kuro-u
Copy link

Y-Kuro-u commented Nov 30, 2022

Hi @sudheer82
you can use _expand__to_dot parameter

Example:

from elasticsearch import Elasticsearch
from elasticsearch_dsl import Q, Search
Q(
    "range",
    _expand__to_dot=False,
    some__field_name={
            "gte": "2022-10-01",
            "lte": "2022-11-30"
    },
),

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