elasticsearch - 提高查询性能

elasticsearch - improve query performance

我正在使用带有 2 个索引的托管 elasticsearch 云,每个索引有 50,000 个文档,其中一个大小约为 300MB(我们正在应用搜索),另一个是 50MB(我们正在应用建议)和还向两个索引添加了查询缓存。

  1. 大小为 300MB 的索引(用于搜索)
    • 此查询需要 1.2 秒到 1.5 秒的响应时间 设置 JSON
{
  "index.blocks.read_only_allow_delete": "false",
  "index.priority": "1",
  "index.query.default_field": [
    "*"
  ],
  "index.write.wait_for_active_shards": "1",
  "index.refresh_interval": "9000s",
  "index.requests.cache.enable": "true",
  "index.analysis.analyzer.edge_ngram_analyzer.filter": [
    "lowercase"
  ],
  "index.analysis.analyzer.edge_ngram_analyzer.tokenizer": "edge_ngram_tokenizer",
  "index.analysis.analyzer.keyword_analyzer.filter": [
    "lowercase",
    "asciifolding",
    "trim"
  ],
  "index.analysis.analyzer.keyword_analyzer.char_filter": [],
  "index.analysis.analyzer.keyword_analyzer.type": "custom",
  "index.analysis.analyzer.keyword_analyzer.tokenizer": "keyword",
  "index.analysis.analyzer.singular_plural_analyzer.type": "snowball",
  "index.analysis.analyzer.edge_ngram_search_analyzer.tokenizer": "lowercase",
  "index.analysis.tokenizer.edge_ngram_tokenizer.token_chars": [
    "letter"
  ],
  "index.analysis.tokenizer.edge_ngram_tokenizer.min_gram": "2",
  "index.analysis.tokenizer.edge_ngram_tokenizer.type": "edge_ngram",
  "index.analysis.tokenizer.edge_ngram_tokenizer.max_gram": "5",
  "index.number_of_replicas": "1"
}
  1. 大小为50MB的索引(用于建议)
    • 此查询需要 0.5 秒到 0.6 秒的响应时间。

设置JSON

{
  "index.blocks.read_only_allow_delete": "false",
  "index.priority": "1",
  "index.query.default_field": [
    "*"
  ],
  "index.write.wait_for_active_shards": "1",
  "index.refresh_interval": "90000s",
  "index.requests.cache.enable": "true",
  "index.analysis.analyzer.edge_ngram_analyzer.filter": [
    "lowercase"
  ],
  "index.analysis.analyzer.edge_ngram_analyzer.tokenizer": "edge_ngram_tokenizer",
  "index.analysis.analyzer.keyword_analyzer.filter": [
    "lowercase",
    "asciifolding",
    "trim"
  ],
  "index.analysis.analyzer.keyword_analyzer.char_filter": [],
  "index.analysis.analyzer.keyword_analyzer.type": "custom",
  "index.analysis.analyzer.keyword_analyzer.tokenizer": "keyword",
  "index.analysis.analyzer.singular_plural_analyzer.type": "snowball",
  "index.analysis.analyzer.edge_ngram_search_analyzer.tokenizer": "lowercase",
  "index.analysis.tokenizer.edge_ngram_tokenizer.token_chars": [
    "letter"
  ],
  "index.analysis.tokenizer.edge_ngram_tokenizer.min_gram": "2",
  "index.analysis.tokenizer.edge_ngram_tokenizer.type": "edge_ngram",
  "index.analysis.tokenizer.edge_ngram_tokenizer.max_gram": "5",
  "index.number_of_replicas": "0"
}

我想增加两个查询的响应时间。

现在 system/elasticsearch 云配置图片 link 添加在下方。

你能帮我提高查询的性能吗?

我想通了并通过将 elasticsearch 安装到我的本地服务器并删除了网络依赖性解决了我的问题。

问题是远程弹性搜索云和较慢的网络。现在,两个查询都在 15 毫秒到 20 毫秒内给我答复。