<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(后置過濾) 在已經計算了聚合之后,`post_filter`應用于搜索請求最后的搜索結果`hits`。其目的最好的例子如下: 想像一下,您正在銷售具有以下屬性的襯衫: ``` 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" } ``` 想象一下,用戶已經指定了兩個過濾器: `color:red`與`brand:gucci`。你只想在搜索結果中顯示 Gucci 制作的紅色襯衫。 通常你會使用[布爾查詢](../../Query_DSL/Compound_queries/Bool_Query.md): ``` GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } } } ``` 但是,您也可以使用分面導航來顯示用戶可以點擊的其他選項的列表。也許你有一個`model`字段,允許用戶將他們的搜索結果限制在紅色的Gucci `t-shirts`或者`dress-shirts`。 這可以通過<a class="pcalibre1 calibre9 pcalibre3 pcalibre2" href="">terms aggregation</a>來完成: ``` GET /shirts/_search { "query": { "bool": { "filter": [ { "term": { "color": "red" }}, { "term": { "brand": "gucci" }} ] } }, "aggs": { "models": { "terms": { "field": "model" } //① } } } ``` ① 返回Gucci最受歡迎的紅色襯衫款式。 但也許你也想告訴用戶Gucci襯衫有多少可用的**其他顏色**。 如果只是在`color`字段上添加`terms`聚合,則只會返回`紅色`,因為您的查詢只返回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`聚合返回 Gucci 的襯衫的流行顏色。③,④`color_red`聚合將限制在`red` Gucci 襯衫下進行款式子聚合⑤最后,`post_filter`從搜索`hits`中除去紅色以外的顏色。
                  <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>

                              哎呀哎呀视频在线观看