<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>

                ThinkChat2.0新版上線,更智能更精彩,支持會話、畫圖、視頻、閱讀、搜索等,送10W Token,即刻開啟你的AI之旅 廣告
                # Post filter 原文鏈接 : [https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-post-filter.html) 譯文鏈接 : [http://www.apache.wiki/pages/editpage.action?pageId=4883094](http://www.apache.wiki/pages/editpage.action?pageId=488308) 貢獻者 : [ping](/display/~wangyangting) 在已經計算了聚合之后,post_filter 應用于搜索請求的最后的搜索命中。 其目的最好通過例子解釋: 想象一下,你賣的有以下屬性的襯衫: ``` PUT /shirts { "mappings": { "item": { "properties": { "brand": { "type": "keyword"}, "color": { "type": "keyword"}, "model": { "type": "keyword"} } } } } PUT /shirts/item/1?refresh { "brand": "gucci", "color": "red", "model": "slim" } ``` 想象一下,用戶已經指定了兩個過濾器: 顏色:紅色,品牌:gucci 。 你只想在搜索結果中顯示 Gucci 制作的紅色襯衫。 通常你會使用布爾查詢: ``` GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } } } ``` 但是,您還希望使用 **_faceted navigation_**??來顯示用戶可以單擊的其他選項的列表。 也許你有一個模型字段,允許用戶將搜索結果限制為紅色的 Gucci T恤或連衣裙。 這可以通過?[`terms`?aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-terms-aggregation.html "Terms Aggregation")?來完成: ``` GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } }, "aggs": { "models": { "terms": { "field": "model" } ① } } } ``` ①?返回 Gucci 最受歡迎的紅色襯衫款式。 但也許你也想告訴用戶有多少 Gucci 襯衫可用其他顏色。 如果只是在顏色字段上添加術語聚合,則只會返回紅色,因為您的查詢只返回 Gucci 的紅色襯衫。 相反,您希望在聚合期間包括所有顏色的襯衫,然后僅將顏色過濾器應用于搜索結果。 這是 post_filter 的目的: ``` GET /shirts/_search { "query": { "bool": { "filter": { "term": { "brand": "gucci" } ① } } }, "aggs": { "colors": { "terms": { "field": "color" } ② }, "color_red": { "filter": { "term": { "color": "red" } ③ }, "aggs": { "models": { "terms": { "field": "model" } ④ } } } }, "post_filter": { "term": { "color": "red" } ⑤ } } ``` | ``` ① ``` | ``` 主查詢現在查找 Gucci 的所有襯衫,而不考慮顏色。 ``` | | ``` ② ``` | ``` colors agg 返回 Gucci 的襯衫的流行顏色。 ``` | | ``` ③ ``` ``` ④ ``` | ``` color_red agg 將模型子聚合限制為紅色 Gucci 襯衫。 ``` | | ``` ⑤ ``` | 最后,post_filter 從搜索命中中除去紅色以外的顏色。 |
                  <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>

                              哎呀哎呀视频在线观看