Well,不要刷屏了

join 类型如何查询子文档

Elasticsearch | 作者 linfq | 发布于2018年03月16日 | 阅读数:2813

my_join字段的类型为join
文档结构如下:
"rq" : 20171013,
"my_join" : {
"name" : "child_2",
"parent" : "000000001"
}
如何查询name=child_2的文档呢?
{
  "query": {
    "term": {
      "my_join": {
        "value": "child_2"
      }
    }
  }
}
有结果

{
  "query": {
    "term": {
      "my_join": {
        "name": "child_2"
      }
    }
  }
}
就报异常了!
有没有哪位大神帮忙回答一下,正确的DSL要怎么写呀?
已邀请:

laoyang360 - 《一本书讲透Elasticsearch》作者,Elastic认证工程师 [死磕Elasitcsearch]知识星球地址:http://t.cn/RmwM3N9;微信公众号:铭毅天下; 博客:https://elastic.blog.csdn.net

赞同来自:

GET my_join_index/_search
{
"query": {
"has_parent" : {
"parent_type" : "question",
"query" : {
"match" : {
"text" : "This is"
}
}
}
}
}

aa1356889

赞同来自:

你试试
{"query": {
"has_parent": {
"parent_type": "父文档type",
"query": {
"term": {
"name": "child_2"
}
}
}
}
}
顺便请教一下 根据jion类型 可以根据子文档排序吗。。有例子吗

要回复问题请先登录注册