Reputation: 413
Using ES 6.1, Python 3, and elasticsearch-dsl, I've got docs with this mapping:
"mappings": {
"doc": {
"properties": {
"id": {"type": "text"},
"prop_a": {"type": "text"},
"prop_b": {
"type": "nested",
"include_in_root": "true",
"properties": {
"title": {"type": "text"},
"prop_bx": {
"type": "nested",
"properties": {
"name": {"type": "text"}
"descr": {"type": "text"}
}
}
for example:
{
"id": "abc123",
"prop_a": "foo",
"prop_b": {
"title": "some title",
"prop_bx": {
"name": "some name"
"descr": "lorem ipsum ipso facto"
}
}}
and I can successfully query the level 2 (prop_b) property 'title' like:
s1=Search().using(client).query('nested',
path='prop_b',
query=Q('match', prop_b__title='some title'))
I've tried many ways to get to the next level down (prop_bx), and my best shot is this, but it gets "400 failed to create query":
s2=Search().using(client).query('nested',
path='prop_b',
query=Q('nested',path='prop_b__propbx'),
query=Q('match', prop_b__propbx__name='some name'))
Not finding answers or even clues in the docs. I can write this in the standard more verbose query form and convert with the .from_dict() method, but then why bother to convert it to elasticsearch-dsl?
Clues? Thanks.
Upvotes: 1
Views: 996
Reputation: 95
Just use . instead of __ on path:
S2=Search().using(client).query('nested',
path='prop_b.probbx',
query=Q('match', prop_b__propbx__name='some name'))
Upvotes: 2