Elasticsearch使用has_parent过滤器中的嵌套对象映射

时间:2015-08-10 19:58:34

标签: elasticsearch

是否可以在has_parent查询或过滤器中使用嵌套对象映射?每当我尝试时,我总是得到:

  

[customers_and_messages] [嵌套]路径[accounts]下的嵌套对象   不是嵌套类型]

映射

{
  "customer": {
    "properties": {
      "name": {
        "analyzer": "name_edge_ngram_analyzer",
        "type": "string"
      },
      "phone_number": {
        "analyzer": "phone_number_edge_ngram_analyzer",
        "type": "string"
      },
      "location_id": {
        "index": "not_analyzed",
        "type": "string"
      },
      "accounts": {
        "type": "nested",
        "properties": {
          "id": {
            "index": "not_analyzed",
            "type": "string"
          },
          "tags": {
            "type": "string"
          },
          "notes": {
            "type": "string"
          }
        }
      }
    }
  }
}

查询

{
  "query": {
    "filtered": {
      "filter": {
        "bool": {
          "must": [
            {
              "has_parent": {
                "type": "customer",
                "filter": {
                  "nested": {
                    "path": "accounts",
                    "filter": {
                      "term": {
                        "accounts.id": "8392f356-d6ec-11e4-8737-b74c1bacfb15"
                      }
                    }
                  }
                }
              }
            }
          ],
          "should": [
            {
              "term": {
                "kind": "task"
              }
            },
            {
              "term": {
                "kind": "alert"
              }
            }
          ]
        }
      }
    }
  }
}

0 个答案:

没有答案