<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國際加速解決方案。 廣告
                ## 按距離排序 檢索結果可以按跟指定點的距離排序: > 提示 > 當你_可以_(_can_)按距離排序時,按距離打分([scoring-by-distance](#scoring-by-distance))通常是一個更好的解決方案。 ```json GET /attractions/restaurant/_search { "query": { "filtered": { "filter": { "geo_bounding_box": { "type": "indexed", "location": { "top_left": { "lat": 40,8, "lon": -74.0 }, "bottom_right": { "lat": 40.4, "lon": -73.0 } } } } } }, "sort": [ { "_geo_distance": { "location": { <1> "lat": 40.715, "lon": -73.998 }, "order": "asc", "unit": "km", <2> "distance_type": "plane" <3> } } ] } ``` - <1> 計算每個文檔中 `location` 字段與指定的 `lat/lon` 點間的距離。 - <2> 以 `公里`(`km`)為單位,將距離設置到每個返回結果的 `sort` 鍵中。 - <3> 使用快速但精度略差的`平面`(`plane`)計算方式。 你可能想問:為什么要制定距離的`單位`(`unit`)呢? 用于排序的話,我們并不關心比較距離的尺度是英里,公里還是光年。 原因是,這個用于排序的值會設置在每個返回結果的 `sort` 元素中。 ```json ... "hits": [ { "_index": "attractions", "_type": "restaurant", "_id": "2", "_score": null, "_source": { "name": "New Malaysia", "location": { "lat": 40.715, "lon": -73.997 } }, "sort": [ 0.08425653647614346 <1> ] }, ... ``` - <1> 賓館距離我們的指定位置距離是 0.084km。 - 你可以通過設置`單位`(`unit`)來讓返回值的形式跟你應用中想要的匹配。 > 提示 > 地理距離排序可以對多個坐標點來使用,不管(這些坐標點)是在文檔中還是排序參數中。 > 使用 `sort_mode` 來指定是否需要使用位置集合的 `最小`(`min`),最大(`max`)或者`平均`(`avg`)距離。 > 這樣就可以返回``離我的工作地和家最近的朋友``這樣的結果了。 ### 按距離打分 有可能距離只是決定返回結果排序的唯一重要因素,不過更常見的情況是距離會和其它因素, 比如全文檢索匹配度,流行程度或者價格一起決定排序結果。 遇到這種場景你需要在查詢分值計算([`function_score` query](function-score-query))中指定方式讓我們把這些因子處理得到一個綜合分。 [decay-functions](decay-functions)中有個一個例子就是地理距離影響排序得分的。 另外按距離排序還有個缺點就是性能:需要對每一個匹配到的文檔都進行距離計算。 而 `function_score`請求,在 [`rescore` phase](rescore-api)階段有可能只需要對前 _n_ 個結果進行計算處理。
                  <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>

                              哎呀哎呀视频在线观看