如何在elasticsearch中存储所有属性的原始值?
我需要聚合的原始值,属性不为a-priory。
更新
想要所有属性
{
"type": "string",
"fields": {
"raw": {
"type": "string",
"index": "not_analyzed"
}
}
}
属性是动态的
提前致谢。
答案 0 :(得分:0)
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
答案 1 :(得分:0)
找到解决方案
ccc <- c(1:5, 11:15, 21:25, 31:35)
}