gpt4 book ai didi

elasticsearch - 如何存储所有属性的原始值?

转载 作者:行者123 更新时间:2023-12-03 03:41:43 25 4
gpt4 key购买 nike

如何存储 elasticsearch 中所有属性的原始值?

我需要原始值进行聚合,属性是未知的。

更新:

希望所有属性都是

{
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}

而属性是动态的

提前致谢。

最佳答案

You have to use PUT method to add data to elasticsearch. 

Example:

`$ curl -XPUT 'http://localhost:9200/products/product/123' -d '{
"ProductID": 123,
"SellingPrice": 1200.00,
"DiscountAmount":0.00,
"Discount": {
"Type": "percentage",
"Amount": 25,
"StartDate": "2014-08-13T12:05:00",
"EndDate": "2014-12-31T12:10:00"
}
}'`

CURL library can be used to send data to your elasticsearch. For testing purpose you can use [chrome sense plugin][1].

For getting aggregation use POST or GET method.

Example:

`$ curl -XGET 'http://localhost:9200/products/product/_search?search_type=count' -d '{
"aggregations": {
"my_agg": {
"terms": {
"field": "SellingPrice"
}
}
}
}
'`

Above example will return aggregation result as below:

`{
"took": 48,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 117,
"max_score": 0,
"hits": []
},
"aggregations": {
"my_agg": {
"doc_count_error_upper_bound": 0,
"sum_other_doc_count": 0,
"buckets": [
{
"key": 1200,
"doc_count": 1
}
]
}
}
}`



[1]: https://chrome.google.com/webstore/detail/sense-beta/lhjgkmllcaadmopgmanpapmpjgmfcfig?hl=en

关于elasticsearch - 如何存储所有属性的原始值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29174101/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com