zoukankan      html  css  js  c++  java
  • 排序

    # 排序
    
    # 通过sort把结果排序
    # desc 降序
    # asc 升序
    
    GET /library/books/_search
    {
      "query": {
        "match_all": {}
      },
      "sort": [
        {
          "price": {
            "order": "desc"
          }
        }
      ]
    }
    {
      "took": 3,
      "timed_out": false,
      "_shards": {
        "total": 5,
        "successful": 5,
        "failed": 0
      },
      "hits": {
        "total": 8,
        "max_score": null,
        "hits": [
          {
            "_index": "library",
            "_type": "books",
            "_id": "8",
            "_score": null,
            "_source": {
              "title": "SOA.Governance.in.Action",
              "price": 33,
              "preview": "Service-oriented architecture, or  SOA , governance involves the process of creating a set of guidelines with which your services need to comply. When you apply good SOA governance practices, you can create high-quality services that can be easily used by your consumers and that behave exactly as expected. With  SOA governance it’s easier to create new services, upgrade existing ones, and monitor the customer and business use of your services.",
              "publish_date": "2014-12-21"
            },
            "sort": [
              33
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "4",
            "_score": null,
            "_source": {
              "title": "Thinking in Python",
              "price": 22,
              "preview": "Welcome! Are you completely new to programming? If not then we presume you will be looking for information about why and how to get started with Python. Fortunately an experienced programmer in any programming language (whatever it may be) can pick up Python very quickly. It's also easy for beginners to use and learn",
              "publish_date": "2015-07-11"
            },
            "sort": [
              22
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "6",
            "_score": null,
            "_source": {
              "title": "RabbitMQ in Action",
              "price": 17,
              "preview": "RabbitMQ is an open source message broker and queueing server that can be used to let disparate applications share data via a common protocol, or to simply queue jobs for processing by distributed workers. It doesn’t matter whether your project is big or small: RabbitMQ can adapt to your needs. Do you want to quickly prototype one of your application components in languag X and be sure you can easily switch it tomorrow to a more performant language? RabbitMQ can help you by decoupling the communication protocol. Do you need to be able to process image uploads for your social website as they arrive, while adding or removing workers with ease? You can use Rabbit queues to store jobs and let the broker perform the load balancing and job distribution for you. Problems like these can be easily and quickly solved by using RabbitMQ; this book is here to show you how to best implement your architec-tures around messaging.",
              "publish_date": "2015-03-05"
            },
            "sort": [
              17
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "2",
            "_score": null,
            "_source": {
              "title": "The Elasticsearch cookbook",
              "price": 15,
              "preview": "One of the main requirements of today's applications is search capability. In the market, we can find a lot of solutions that answer this need, both in commercial as well as the open source world. One of the most used libraries for searching is Apache Lucene. This library is the base of a large number of search solutions such as Apache Solr, Indextank, and ElasticSearch.",
              "publish_date": "2015-05-12"
            },
            "sort": [
              15
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "7",
            "_score": null,
            "_source": {
              "title": "Rails.3.in.Action",
              "price": 11,
              "preview": "This book has been through quite the development process! It began in 2008 with Michael Ivey, Yehuda Katz, and Ezra Zygmuntowicz and was called Merb in Action. Since then it has changed name and hands a couple of times, winding up with people such as James Cox and the great Mike Gunderloy, the latter of whom is probably most famous for his work on Factsheet Five and many . NET books, not to mention being one of the founding members of the RailsBridge (http://railsbridge.org) organization.",
              "publish_date": "2015-08-31"
            },
            "sort": [
              11
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "3",
            "_score": null,
            "_source": {
              "title": "Elasticsearch Blueprints",
              "price": 9,
              "preview": "This book starts with the creation of a Google-like web search service, enabling you to generate your own search results. You will then learn how an e-commerce website can be built using Elasticsearch. We will discuss various approaches in getting relevant content up the results, such as relevancy based on how well a query matched the text, time-based recent documents, geographically nearer items, and other frequently used approaches.",
              "publish_date": "2015-06-01"
            },
            "sort": [
              9
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "5",
            "_score": null,
            "_source": {
              "title": "MongoDB in Action",
              "price": 7,
              "preview": "This book is for application developers and  DBA s wanting to learn MongoDB from the ground up. If you’re new to MongoDB, you’ll find in this book a tutorial that moves at a comfortable pace. If you’re already a user, the more detailed reference sections in the book will come in handy and should fill any gaps in your knowledge. In terms of depth, the material should be suitable for all but the most advanced users.",
              "publish_date": "2014-06-21"
            },
            "sort": [
              7
            ]
          },
          {
            "_index": "library",
            "_type": "books",
            "_id": "1",
            "_score": null,
            "_source": {
              "title": "Elasticsearch: The Definitive Guide",
              "price": 5,
              "preview": "Elasticsearch is a distributed, scalable, real-time search and analytics engine. It ena‐bles you to search, analyze, and explore your data, often in ways that you did not anticipate at the start of a project. It exists because raw data sitting on a hard drive is just not useful.",
              "publish_date": "2015-02-08"
            },
            "sort": [
              5
            ]
          }
        ]
      }
    }

  • 相关阅读:
    在ubuntu下递归追索一个包的所有必要依赖项apt_dep.sh
    龙芯系统下,GTK与OPENGL共舞
    Linux应用程序自行开启Core Dump生成功能
    Daliy Algorithm -- day 102
    Daliy Algorithm -- day 101
    Daliy Algorithm -- day 100
    Daliy Algorithm -- day 99
    Daliy Algorithm -- day 98
    Daliy Algorithm -- day 97
    使用R语言进行简单的线性回归
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13349685.html
Copyright © 2011-2022 走看看