<ruby id="bdb3f"></ruby>

    <p id="bdb3f"><cite id="bdb3f"></cite></p>

      <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
        <p id="bdb3f"><cite id="bdb3f"></cite></p>

          <pre id="bdb3f"></pre>
          <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

          <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
          <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

          <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                <ruby id="bdb3f"></ruby>

                合規國際互聯網加速 OSASE為企業客戶提供高速穩定SD-WAN國際加速解決方案。 廣告
                ## 1. 基礎排序 1. 默認排序規則 默認情況下,是按照_score降序排序的,然而,某些情況下,可能沒有有用的_score,比如說filter ~~~ GET /_search { "query" : { "bool" : { "filter" : { "term" : { "author_id" : 1 } } } } } ~~~ 當然,也可以是constant_score,只使用過濾器 ~~~ GET /_search { "query" : { "constant_score" : { "filter" : { "term" : { "author_id" : 1 } } } } } ~~~ 2. 自定義排序規則 query后邊跟sort ~~~ GET /company/employee/_search { "query": { "constant_score": { "filter": { "range": { "age": { "gte": 30 } } } } }, "sort": [ { "join_date": { # 指定要排序的field "order": "asc" } } ] } ~~~ ## 2. string字段排序 1. 對一個字段,指定一個用于搜索,一個用于排序 如果對一個string field進行排序,結果往往不準確,因為分詞后是多個單詞,再排序就不是我們想要的結果了 通常解決方案是,將一個string field建立兩次索引,一個分詞,用來進行搜索;一個不分詞,用來進行排序 ~~~ PUT /website { "mappings": { "article": { "properties": { "title": { "type": "text", "fields": { "raw": { "type": "string", "index": "not_analyzed" # 不分詞 } }, "fielddata": true # 正排索引 }, "content": { "type": "text" }, "post_date": { "type": "date" }, "author_id": { "type": "long" } } } } } PUT /website/article/1 { "title": "first article", "content": "this is my second article", "post_date": "2017-01-01", "author_id": 110 } { "took": 2, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 3, "max_score": 1, "hits": [ { "_index": "website", "_type": "article", "_id": "2", "_score": 1, "_source": { "title": "first article", "content": "this is my first article", "post_date": "2017-02-01", "author_id": 110 } }, { "_index": "website", "_type": "article", "_id": "1", "_score": 1, "_source": { "title": "second article", "content": "this is my second article", "post_date": "2017-01-01", "author_id": 110 } }, { "_index": "website", "_type": "article", "_id": "3", "_score": 1, "_source": { "title": "third article", "content": "this is my third article", "post_date": "2017-03-01", "author_id": 110 } } ] } } GET /website/article/_search { "query": { "match_all": {} }, "sort": [ { "title.raw": { "order": "desc" } } ] } ~~~
                  <ruby id="bdb3f"></ruby>

                  <p id="bdb3f"><cite id="bdb3f"></cite></p>

                    <p id="bdb3f"><cite id="bdb3f"><th id="bdb3f"></th></cite></p><p id="bdb3f"></p>
                      <p id="bdb3f"><cite id="bdb3f"></cite></p>

                        <pre id="bdb3f"></pre>
                        <pre id="bdb3f"><del id="bdb3f"><thead id="bdb3f"></thead></del></pre>

                        <ruby id="bdb3f"><mark id="bdb3f"></mark></ruby><ruby id="bdb3f"></ruby>
                        <pre id="bdb3f"><pre id="bdb3f"><mark id="bdb3f"></mark></pre></pre><output id="bdb3f"></output><p id="bdb3f"></p><p id="bdb3f"></p>

                        <pre id="bdb3f"><del id="bdb3f"><progress id="bdb3f"></progress></del></pre>

                              <ruby id="bdb3f"></ruby>

                              哎呀哎呀视频在线观看