使用 ES 6.1、Python 3 和 elasticsearch-dsl,我得到了具有此映射的文档:
"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"}
}
}
例如:
{
"id": "abc123",
"prop_a": "foo",
"prop_b": {
"title": "some title",
"prop_bx": {
"name": "some name"
"descr": "lorem ipsum ipso facto"
}
}}
我可以成功查询 2 级(prop_b)属性“标题”,例如:
s1=Search().using(client).query('nested',
path='prop_b',
query=Q('match', prop_b__title='some title'))
我已经尝试了很多方法来进入下一个级别(prop_bx),我最好的方法是这个,但它得到“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'))
在文档中找不到答案甚至线索。我可以用标准的更详细的查询表单来编写它并使用 .from_dict() 方法进行转换,但是为什么还要麻烦将其转换为 elasticsearch-dsl 呢?
线索?谢谢。