0

如果我把这样的文件:

$ curl -XPOST "http://localhost:9200/test/test/" -d '
{
  "books": {
    "id1": {
        "name": "Hello World!"
    },
    "id2": {
        "name": "Hitchhiker Guide To The Galaxy"
    }
  }
}'

然后它创建一个像这样的映射:

$ curl -XGET "http://localhost:9200/test/test/_mapping"
{
  "test":{
    "mappings":{
      "test":{
        "properties":{
          "books":{
            "properties":{
              "id1":{
                "properties":{
                  "name":{
                    "type":"string"
                  }
                }
              },
              "id2":{
                "properties":{
                  "name":{
                    "type":"string"
                  }
                }
              }
            }
          }
        }
      }
    }
  }
}

“books”对象中的属性/键是动态的,映射会无限增长。如何让 ES 不查看“books”的键并使其了解“books”中的每个值都属于同一类型?例如,映射不应该包含每个图书 ID 的新条目。

4

1 回答 1

0

You can store only one document at a time, unless you use bulk upload. A single document could look like this:

$ curl -XPOST "http://localhost:9200/test/test/" -d '
{
    "id": "id1",
    "name": "Hello World!"
}'

Or:

$ curl -XPOST "http://localhost:9200/test/test/id1" -d '
{
    "name": "Hello World!"
}'
于 2015-10-20T07:25:32.573 回答