• <noscript id="ommkm"><source id="ommkm"></source></noscript>
  • <table id="ommkm"><option id="ommkm"></option></table>
  • <noscript id="ommkm"><source id="ommkm"></source></noscript>
    <rt id="ommkm"><option id="ommkm"></option></rt>
  • <noscript id="ommkm"></noscript>
  • 發布時間:2020-09-28 22:43 原文鏈接: Elasticsearch性能優化指南(十二)

    使用Profile API調整查詢

    您還可以使用Profile API分析查詢和聚合每個部分的成本。這可能使您可以調整查詢花費更少成本,從而獲得正面的性能結果并減少負載。另請注意,可以在Search Profiler中輕松查看Profile API負載以提高可讀性,Search Profiler是所有X-Pack許可證(包括免費的X-Pack Basic許可證)中均可使用的Kibana開發工具UI。

    對Profile API的一些警告是:

    Profile API作為調試工具增加了搜索執行的大量開銷,并且還可能產生非常冗長的輸出

    給定增加的開銷,得出的花費時間指標可能不是實際花費時間,但是可以在子句之間進行比較以獲取相對時間差異

    Profile API最適合用于研究查詢中花費最多開銷的子句后面的可能原因,但并非旨在準確衡量每個子句的時間

    使用index_phrases進行更快的短語查詢

    文本字段具有index_phrases選項,該選項索引2個,并且查詢解析器會自動利用該選項來運行不帶斜率的詞組查詢。如果您的用例涉及運行大 量短語查詢,則可以大大加快查詢速度。

    使用index_prefixes進行更快的前綴查詢

    文本字段具有index_prefixes選項,該選項為所有term的前綴編制索引,并由查詢解析器自動利用以運行前綴查詢。如果您的用例涉及運行大量前綴查詢,則可以大大加快查詢速度。

    使用constant_keyword加快過濾

    調整磁盤使用率

    禁用不需要的功能

    默認情況下,Elasticsearch為大多數字段編入索引并將doc值添加到大多數字段,以便可以立即搜索和聚合匯總它們。例如,如果您有一個名為foo的數字字段,需要在其上運行直方圖,但您永遠不需要對其進行過濾,則可以安全地在 mappings中禁用對此字段的索引:

    text字段在索引中存儲歸一化因子,以便能夠對文檔進行評分。如果您只需要 text字段上的匹配功能但不關心產生的分數,則可以將Elasticsearch配置為不將 norms 寫入索引:

    curl -X PUT "localhost:9200/index?pretty" -H 'Content-Type: application/json' -d'{"mappings": {"properties": {"foo": {"type": "text","norms": false      }    }  }}'

    默認情況下,文本字段還將頻率和位置存儲在索引中。頻率用于計算分數,位置用于運行 phrase 查詢。如果您不需要運行 phrase 查詢,可以告訴Elasticsearch不要索引位置信息:

    curl -X PUT "localhost:9200/index?pretty" -H 'Content-Type: application/json' -d'{"mappings": {"properties": {"foo": {"type": "text","index_options": "freqs"      }    }  }}'

    此外,如果您既不計分,也可以將Elasticsearch配置為僅對每個 term的匹配文檔編制索引。您仍然可以在此字段上進行搜索,但是詞組查詢將引發錯誤,并且評分將假定 term在每個文檔中僅出現一次。

    curl -X PUT "localhost:9200/index?pretty" -H 'Content-Type: application/json' -d'{"mappings": {"properties": {"foo": {"type": "text","norms": false,"index_options": "freqs"      }    }  }}'


  • <noscript id="ommkm"><source id="ommkm"></source></noscript>
  • <table id="ommkm"><option id="ommkm"></option></table>
  • <noscript id="ommkm"><source id="ommkm"></source></noscript>
    <rt id="ommkm"><option id="ommkm"></option></rt>
  • <noscript id="ommkm"></noscript>
  • 国产精品单位女同事在线