简体   繁体   English

Elasticsearch映射中的显式数组类型

[英]explicit array type in mapping in elasticsearch

Is there a way to explicitly specify that a property is expected to be an array in the mapping? 有没有一种方法可以明确指定属性应为映射中的数组?

Here is the relevant part of my json schema to generate the mapping: myArray should be an array. 这是生成映射的json模式的相关部分:myArray应该是一个数组。 This is implicit done if i put 'myArray' with more than one value into the index. 如果我将具有多个值的“ myArray”放入索引,则这是隐式完成的。 But i want that 'myArray' is also handled as array (in the response) if there is only one or zero values. 但是我希望如果只有一个或零个值,“ myArray”也可以作为数组(在响应中)处理。 Otherwise my elasticsearch clients are confused with the mapping from json to c# objects (Newtonsoft.Json). 否则,我的elasticsearch客户会从json到c#对象的映射(Newtonsoft.Json)感到困惑。

"myArray":{
    "properties":{
        "start":{
            "type":"date",
            "format":"dateOptionalTime"
        },
        "end":{
            "type":"date",
            "format":"dateOptionalTime"
        },
        "nr":{
            "type":"long"
        }
    }
}

In ES 1.x everything is treated as an array. 在ES 1.x中,所有内容均视为数组。 I would suggest upgrading. 我建议升级。

http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/_return_values.html http://www.elasticsearch.org/guide/zh-CN/elasticsearch/reference/current/_return_values.html

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM