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

                ??一站式輕松地調用各大LLM模型接口,支持GPT4、智譜、豆包、星火、月之暗面及文生圖、文生視頻 廣告
                ##搜索選項 一些查詢字符串(query-string)可選參數能夠影響搜索過程。 ####preference(偏愛) `preference`參數允許你控制使用哪個分片或節點來處理搜索請求。她接受如下一些參數 `_primary`, `_primary_first`, `_local`, `_only_node:xyz`, `_prefer_node:xyz`和`_shards:2,3`。這些參數在文檔[搜索偏好(search preference)](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html)里有詳細描述。 然而通常最有用的值是一些隨機字符串,它們可以避免結果震蕩問題(the _bouncing results_ problem)。 #####結果震蕩(Bouncing Results) * 想像一下,你正在按照`timestamp`字段來對你的結果排序,并且有兩個document有相同的timestamp。由于搜索請求是在所有有效的分片副本間輪詢的,這兩個document可能在原始分片里是一種順序,在副本分片里是另一種順序。 * 這就是被稱為_結果震蕩(bouncing results)_的問題:用戶每次刷新頁面,結果順序會發生變化。避免這個問題方法是對于同一個用戶總是使用同一個分片。方法就是使用一個隨機字符串例如用戶的會話ID(session ID)來設置`preference`參數。 ###timeout(超時) 通常,協調節點會等待接收所有分片的回答。如果有一個節點遇到問題,它會拖慢整個搜索請求。 `timeout`參數告訴協調節點最多等待多久,就可以放棄等待而將已有結果返回。返回部分結果總比什么都沒有好。 搜索請求的返回將會指出這個搜索是否超時,以及有多少分片成功答復了: ``` js ... "timed_out": true, (1) "_shards": { "total": 5, "successful": 4, "failed": 1 (2) }, ... ``` -------------------------------------------------- (1) 搜索請求超時。 (2) 五個分片中有一個沒在超時時間內答復。 如果一個分片的所有副本都因為其他原因失敗了——也許是因為硬件故障——這個也同樣會反映在該答復的`_shards`部分里。 ### routing(路由選擇) 在路由值那節里,我們解釋了如何在建立索引時提供一個自定義的`routing`參數來保證所有相關的document(如屬于單個用戶的document)被存放在一個單獨的分片中。在搜索時,你可以指定一個或多個`routing` 值來限制只搜索那些分片而不是搜索index里的全部分片: ``` js GET /_search?routing=user_1,user2 ``` 這個技術在設計非常大的搜索系統時就會派上用場了。我們在規模(scale)那一章里詳細討論它。 ### search_type(搜索類型) 雖然`query_then_fetch`是默認的搜索類型,但也可以根據特定目的指定其它的搜索類型,例如: ``` js GET /_search?search_type=count ``` ___count(計數)___ `count(計數)`搜索類型只有一個`query(查詢)`的階段。當不需要搜索結果只需要知道滿足查詢的document的數量時,可以使用這個查詢類型。 ___query_and_fetch(查詢并且取回)___ `query_and_fetch(查詢并且取回)`搜索類型將查詢和取回階段合并成一個步驟。這是一個內部優化選項,當搜索請求的目標只是一個分片時可以使用,例如指定了`routing(路由選擇)`值時。雖然你可以手動選擇使用這個搜索類型,但是這么做基本上不會有什么效果。 ___dfs_query_then_fetch___ 和 ___dfs_query_and_fetch___ `dfs`搜索類型有一個預查詢的階段,它會從全部相關的分片里取回項目頻數來計算全局的項目頻數。我們將在relevance-is-broken(相關性被破壞)里進一步討論這個。 ___scan(掃描)___ `scan(掃描)`搜索類型是和`scroll(滾屏)`API連在一起使用的,可以高效地取回巨大數量的結果。它是通過禁用排序來實現的。我們將在下一節_scan-and-scroll(掃描和滾屏)_里討論它。 <!-- === Search Options A few ((("search options")))optional query-string parameters can influence the search process. ==== preference The `preference` parameter allows((("preference parameter")))((("search options", "preference"))) you to control which shards or nodes are used to handle the search request. It accepts values such as `_primary`, `_primary_first`, `_local`, `_only_node:xyz`, `_prefer_node:xyz`, and `_shards:2,3`, which are explained in detail on the http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-request-preference.html[search `preference`] documentation page. However, the most generally useful value is some arbitrary string, to avoid the _bouncing results_ problem.((("bouncing results problem"))) [[bouncing-results]] .Bouncing Results **** Imagine that you are sorting your results by a `timestamp` field, and two documents have the same timestamp. Because search requests are round-robined between all available shard copies, these two documents may be returned in one order when the request is served by the primary, and in another order when served by the replica. This is known as the _bouncing results_ problem: every time the user refreshes the page, the results appear in a different order. The problem can be avoided by always using the same shards for the same user, which can be done by setting the `preference` parameter to an arbitrary string like the user's session ID. **** ==== timeout By default, the coordinating node waits((("search options", "timeout"))) to receive a response from all shards. If one node is having trouble, it could slow down the response to all search requests. The `timeout` parameter tells((("timeout parameter"))) the coordinating node how long it should wait before giving up and just returning the results that it already has. It can be better to return some results than none at all. The response to a search request will indicate whether the search timed out and how many shards responded successfully: [source,js] -------------------------------------------------- ... "timed_out": true, <1> "_shards": { "total": 5, "successful": 4, "failed": 1 <2> }, ... -------------------------------------------------- <1> The search request timed out. <2> One shard out of five failed to respond in time. If all copies of a shard fail for other reasons--perhaps because of a hardware failure--this will also be reflected in the `_shards` section of the response. [[search-routing]] ==== routing In <<routing-value>>, we explained how a custom `routing` parameter((("search options", "routing")))((("routing parameter"))) could be provided at index time to ensure that all related documents, such as the documents belonging to a single user, are stored on a single shard. At search time, instead of searching on all the shards of an index, you can specify one or more `routing` values to limit the search to just those shards: [source,js] -------------------------------------------------- GET /_search?routing=user_1,user2 -------------------------------------------------- This technique comes in handy when designing very large search systems, and we discuss it in detail in <<scale>>. [[search-type]] ==== search_type While `query_then_fetch` is the default((("query_then_fetch search type")))((("search options", "search_type")))((("search_type"))) search type, other search types can be specified for particular purposes, for example: [source,js] -------------------------------------------------- GET /_search?search_type=count -------------------------------------------------- `count`:: The `count` search type has only a `query` phase.((("count search type"))) It can be used when you don't need search results, just a document count or <<aggregations,aggregations>> on documents matching the query. `query_and_fetch`:: The `query_and_fetch` search type ((("query_and_fetch serch type")))combines the query and fetch phases into a single step. This is an internal optimization that is used when a search request targets a single shard only, such as when a <<search-routing,`routing`>> value has been specified. While you can choose to use this search type manually, it is almost never useful to do so. `dfs_query_then_fetch` and `dfs_query_and_fetch`:: The `dfs` search types((("dfs search types"))) have a prequery phase that fetches the term frequencies from all involved shards in order to calculate global term frequencies. We discuss this further in <<relevance-is-broken>>. `scan`:: The `scan` search type is((("scan search type"))) used in conjunction with the `scroll` API ((("scroll API")))to retrieve large numbers of results efficiently. It does this by disabling sorting. We discuss _scan-and-scroll_ in the next section. -->
                  <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>

                              哎呀哎呀视频在线观看