elasticsearch文档中有多级字段好吗?

时间:2019-05-02 15:14:24

标签: elasticsearch

elasticsearch文档中具有多级字段好吗?

如果是,如何使用嵌套字段搜索文档

我没有看到有关Elasticsearch文档的文档https://www.elastic.co/guide/en/elasticsearch/reference/current/index.html

多层是指嵌套字段

{
 "account_number": 0,
    "balance": 16623,
    "firstname": "Bradshaw",
    "lastname": "Mckenzie",
    "age": 29,
    "gender": "F",
    "address": {
        "244 Columbus Place",
        "employer": "Euron",

        "email": {
            "personal":"bradshawmckenzie@euron.com",
            "work": "bradshawmckenzie@euron.com"
        }
        "city": "Hobucken",
        "state": "CO"
    }
}```

In about document address and email inner objects

2 个答案:

答案 0 :(得分:0)

是的,具有多个级别的对象完全可以。

但是,您当前的JSON文档无效。我认为应该更像这样。

GET my-index/_search
{
  "query": {
    "match": {
      "email.personal": "bradshawmckenzie@euron.com"
    }
  }
}

要访问内部对象,可以使用点表示法。例如:

versionRoomPoolList

答案 1 :(得分:0)

Elasticsearch中有多种方法可以具有“多个级别”,每种方法各有利弊。下面的文章很好地解释了它们: https://www.elastic.co/blog/managing-relations-inside-elasticsearch