• linkedu视频
  • 平面设计
  • 电脑入门
  • 操作系统
  • 办公应用
  • 电脑硬件
  • 动画设计
  • 3D设计
  • 网页设计
  • CAD设计
  • 影音处理
  • 数据库
  • 程序设计
  • 认证考试
  • 信息管理
  • 信息安全
菜单
linkedu.com
导航菜单
  • 网页制作
  • 数据库
  • 程序设计
  • 操作系统
  • CMS教程
  • 游戏攻略
  • 脚本语言
  • 平面设计
  • 软件教程
  • 网络安全
  • 电脑知识
  • 服务器
  • 视频教程
  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx
您的位置:首页 > 服务器 >云计算 > Elasticsearch之Nested Sorting,elasticsearch

Elasticsearch之Nested Sorting,elasticsearch

作者:网友 字体:[增加 减小] 来源:互联网

本文主要包含elasticsearch nested,elasticsearch,elasticsearch教程,elasticsearch官网,elasticsearch安装等服务器相关知识,网友希望可以进行参考

Elasticsearch之Nested Sorting,elasticsearch


                                                    

                                                      (这是一个小系列:请戳:Elasticsearch之Nested(嵌套)系列,查看其他nested相关文章)


         It is possible to sort by the value of a nested field, even though the value exists in a separate nested document. To make the result 

more interesting, we will add another record:

  尽管存在于独立的nested文本内,基于nested字段的值排序还是可行的。为了让结果更有意思,让我们增加其他的记录:

curl -XPUT 'localhost:9200/my_index/blog/2' -d '
{
  "title": "Investment secrets",
  "body":  "What they don't tell you ...",
  "tags":  [ "shares", "equities" ],
  "comments": [
    {
      "name":    "Mary Brown",
      "comment": "Lies, lies, lies",
      "age":     42,
      "stars":   1,
      "date":    "2014-10-18"
    },
    {
      "name":    "John Smith",
      "comment": "You're making it up!",
      "age":     28,
      "stars":   2,
      "date":    "2014-10-16"
    }
  ]
}

             Imagine that we want to retrieve blog posts that received comments in October, ordered by the lowest number of stars that each blog

 post received. The search request would look like this:

设想我们想要检索在10月份被评论的博客文章,同时按每篇文章收到的最低星级排序。检索请求应该类似如下:

curl -XPUT 'localhost:9200/_search' -d '
{
  "query":{
     "nested":{
	    "path":"comments",
		"filter":{
		   "range":{
		      "comments.date":{
			      "gte":"2014-10-01",
				  "lt":"2014-11-01"
			  }
		   }
		}
	 }
  },
  "sort":{
     "comments.stars":{
	     "order":"asc",
		 "mode": "min",
		 "nested_filter":{
		     "range":{
			    "comments.date":{
				   "gte":"2014-10-01",
				   "lt":"2014-11-01"
				}
			 }
		 }
	 }
  }
}

           Why do we need to repeat the query conditions in the nested_filter? The reason is that sorting happens after the query has been executed. 

The query matches blog posts that received comments in October, but it returns blog post documents as the result. If we didn’t include the 

nested_filter clause, we would end up sorting based on any comments that the blog post has ever received, not just those received in October.

         为什么我们要在nested_filter内重复查询条件?原因是排序发生在查询执行结束后。查询匹配10月收到评论的博客文章,但是它返回博客文章

文本作为结果。如果我们不包括nested_filter语块,那么最终会基于返回的博客文章的所有评论进行排序,而不是在10月份收到的评分。

(!!!根据自己有限的elasticsearch使用经验,这点非常值得各位读者重视!!!)


原文:http://www.elastic.co/guide/en/elasticsearch/guide/current/nested-sorting.html



分享到:QQ空间新浪微博腾讯微博微信百度贴吧QQ好友复制网址打印

您可能想查找下面的文章:

  • Elasticsearch之Nested Query,elasticsearch
  • Elasticsearch之Nested Aggregation,elasticsearch
  • Elasticsearch之Nested Object Mapping,elasticsearch
  • Elasticsearch之Nested Sorting,elasticsearch
  • Elasticsearch之Nested(嵌套)系列,elasticsearch

相关文章

  • OpenStack之swift安装笔记,openstackswift
  • Hadoop集群优化,hadoop集群
  • 说说hadoop,hadoop
  • Hadoop之——HBase笔记,hadoophbase
  • hadoop权威指南(第四版)要点翻译(1)——Foreword and Preface,hadoopforeword
  • ganglia安装教程,ganglia教程
  • hive schema详解,hiveschema
  • 几本京东上的CISCO云计算相关书籍,cisco相关书籍
  • HBase入门5(集群),hbase入门5集群
  • HBase RegionServer详解(未完),hbaseregionserver

文章分类

  • windows
  • 服务器硬件
  • 服务器运维
  • 云计算
  • 虚拟化
  • IIS教程
  • Linux
  • Apache
  • Ftp
  • DNS
  • Nginx

最近更新的内容

    • 机器学习数学基础- gradient descent算法(上),gradientdescent
    • HBase,hbase安装
    • JOIN操作,数据库join操作
    • 基于Hive及Sqoop的每日PV、UV、IP定时分析,hivesqoop
    • Hbase集群扩展,hbase集群
    • hadoop中NameNode、DataNode和Client三者之间协作关系及通信方式介绍,hadoopnamenode
    • Hadoop之——分布式集群安装过程简化版,hadoop集群简化版
    • Centos 64下实现socket通信,centos64下
    • redhat7.0下mongodb主从搭配,redhat7.0mongodb
    • R.net获取R中股票的dataframe中的data,r.netdataframe

关于我们 - 联系我们 - 免责声明 - 网站地图

©2020-2025 All Rights Reserved. linkedu.com 版权所有