とクエリを分析:
GET /_search
{
"query": {
"constant_score": {
"filter": {
"term": {
"price": 20
}
}
}
}
}
クエリ2 Slow Logを使用すると、クエリをログに記録し、フェーズをログファイルにフェッチできます。設定が非常に簡単です。インデックスごとに「低速クエリ」という意味を定義できます。 「サンプル」という名前のインデックスの
簡単な例(テスト目的のために、それが「0」に設定した時間にログインされます - あなたはあなた自身のしきい値を設定することができます):
最初のインデックスを閉じる:
curl -X POST http://127.0.0.1:9200/sample/_close
を
curl -X PUT \
'http://127.0.0.1:9200/sample/_settings?preserve_existing=true' \
-d '{
"index.indexing.slowlog.threshold.index.debug" : "0s",
"index.search.slowlog.threshold.fetch.debug" : "0s",
"index.search.slowlog.threshold.query.debug" : "0s"
}'
オープンインデックス:
curl -X POST http://127.0.0.1:9200/sample/_open
は、次にスローログを設定します
あなたのポストで提供短いクエリを実行した後(私は5つの破片を持っていると、クエリがそれらのそれぞれに対して実行される):
[index.search.slowlog.query] [sample][1] took[594.1micros], ..., source[{"query":{"term":{"price":{"value":33,"boost":1.0}}}}],
[index.search.slowlog.query] [sample][3] took[649.4micros], ..., source[{"query":{"term":{"price":{"value":33,"boost":1.0}}}}],
[index.search.slowlog.query] [sample][4] took[575.6micros], ..., source[{"query":{"term":{"price":{"value":33,"boost":1.0}}}}],
[index.search.slowlog.query] [sample][2] took[1.2ms], ..., source[{"query":{"term":{"price":{"value":33,"boost":1.0}}}}],
[index.search.slowlog.query] [sample][0] took[4.3ms], ..., source[{"query":{"term":{"price":{"value":33,"boost":1.0}}}}],
...
をあなたはあなたのポストで提供長いクエリを実行した後:
[index.search.slowlog.query] [sample][1] took[13.2ms], ..., source[{"query":{"constant_score":{"filter":{"term":{"price":{"value":33,"boost":1.0}}},"boost":1.0}}}],
[index.search.slowlog.query] [sample][4] took[13.2ms], ..., source[{"query":{"constant_score":{"filter":{"term":{"price":{"value":33,"boost":1.0}}},"boost":1.0}}}],
[index.search.slowlog.query] [sample][3] took[14.7ms], ..., source[{"query":{"constant_score":{"filter":{"term":{"price":{"value":33,"boost":1.0}}},"boost":1.0}}}],
[index.search.slowlog.query] [sample][2] took[15.5ms], ..., source[{"query":{"constant_score":{"filter":{"term":{"price":{"value":33,"boost":1.0}}},"boost":1.0}}}],
[index.search.slowlog.query] [sample][0] took[15.5ms], ..., source[{"query":{"constant_score":{"filter":{"term":{"price":{"value":33,"boost":1.0}}},"boost":1.0}}}],
...
もちろん、これは1回の試行に過ぎませんが、詳細なテストや分析には非常に役立ちます。