elastcisearch 嵌套查询
2017-12-01 00:46
190 查看
查找官方文档
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_nested_sorting_example
还可以参见
http://blog.csdn.net/u012332735/article/details/62222953
结果
https://www.elastic.co/guide/en/elasticsearch/reference/5.0/search-request-sort.html#_nested_sorting_example
还可以参见
http://blog.csdn.net/u012332735/article/details/62222953
PUT /testnexted/my_type/1?refresh { "product": "xxx", "offer": [{ "price": 45, "color": "blue" }, { "price": 18, "color": "red" }, { "price": 45, "color": "red" }, { "price": 28, "color": "red" } ] } PUT /testnexted/my_type/2?refresh { "product": "xxx56", "offer": [{ "price": 23, "color": "blue" }, { "price": 10, "color": "red" }, { "price": 58, "color": "red" }, { "price": 32, "color": "red" } ] } //defined PUT /testnexted/ { "mappings": { "my_type": { "properties": { "offer": { "type": "nested" }, "price": { "type": "integer" }, "color": { "type": "keyword" } } } } } //search POST /testnexted/_search?pretty //sort POST /testnexted/_search { "sort" : [ { "offer.price" : { "order" : "asc", "nested_path" : "offer", "nested_filter" : { "term" : { "offer.color" : "blue" } } } } ] } //数组求平均值在排序 POST /testnexted/_search { "sort" : [ { "offer.price" : { "mode" : "avg", "order" : "asc", "nested_path" : "offer", "nested_filter" : { "term" : { "offer.color" : "blue" } } } } ] }
结果
{ "took": 0, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 2, "max_score": null, "hits": [ { "_index": "testnexted", "_type": "my_type", "_id": "2", "_score": null, "_source": { "product": "xxx56", "offer": [ { "price": 23, "color": "blue" }, { "price": 10, "color": "red" }, { "price": 58, "color": "red" }, { "price": 32, "color": "red" } ] }, "sort": [ 23 ] }, { "_index": "testnexted", "_type": "my_type", "_id": "1", "_score": null, "_source": { "product": "xxx", "offer": [ { "price": 45, "color": "blue" }, { "price": 18, "color": "red" }, { "price": 45, "color": "red" }, { "price": 28, "color": "red" } ] }, "sort": [ 45 ] } ] } }
相关文章推荐
- elk,logstash ->elastcisearch 429
- elastcisearch 对查询操作的 explain 就像自己项目里的页签统计标识
- Elastcisearch记录
- ElastciSearch常用APi
- High disk watermark in elastcisearch
- 数据库操作,内外联查询,分组查询,嵌套查询,交叉查询,多表查询,语句小结
- Computer Archiecture 3rd Edition 读书笔记(1)-Tomasulo算法
- 从ABS定制内核[转自arch wiki]
- SOA Arch
- SDK 3.0的UISearchDisplayerController不用IB实现的范例
- SQL嵌套查询引起的性能问题分析
- GoldArch官方博客
- 数据库Standby中的几个概念 - LGWR, ARCH,ASYNC,SYNC,AFFIRM
- 嵌套查询存在父子关系的表
- start_kernel->setup_arch->paging_init->bootmem_init() 之 2
- Oracle DBWR,LGWR,CKPT,ARCH 触发条件 总结
- Linux启动中setup_arch分析
- (二)start_kernel分析二---之setup_arch()函数分析
- iphone-common-codes-ccteam源代码 CCUISearchBar.h
- arch安装及配置xfce4桌面