对于Elasticsearch中的_search查询,如何获取查询执行计划进行复杂度分析?

eni9jsuy  于 2023-08-03  发布在  ElasticSearch
关注(0)|答案(1)|浏览(100)

我们正在遵循YouTube视频Elasticsearch text analysis and full text search - a quick introduction中的一个示例。
除了视频之外,我们还对

  • “全文索引”和
  • 即“正则表达式”。
    我们的问题:

对于Elasticsearch,是否有类似于传统SQL数据库的EXPLAIN (query execution plan)?我们要分析以上两个特征的计算复杂度。

测试步骤:

# Create index
PUT /reviews
{
  "mappings": {
    "properties": {
      "review": {
        "type": "text"
      }
    }
  }
}

# Populate data
POST reviews/_bulk
{ "create": {} }
{ "review": "The denumidifier helps dry my laundry really quickly. It's great looking, efficient, and I use the water from the tank to water my plants. It's quite noisy, though." }
{ "create": {} }
{ "review": "The rabbit is really wonderful! It runs quickly, my children love it, and it sleeps in the laundry pile." }
{ "create": {} }
{ "review": "Full text search is powerful, but I wish it did my laundry." }

# Self-designed Test:
# The full text analyzer keeps the keyword "laundry". So, for an incomplete spelling "laundr", 
# the full text index does not return a match, however, 
# the regular expression ".*laundr.*" still matches.

GET reviews/_search
{
  "query": {
    "match": {
      "review": "laundry"
    }
  }
}

GET reviews/_search
{
  "query": {
    "match": {
      "review": "laundr"
    }
  }
}

# https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-regexp-query.html#regexp-query-notes
GET /reviews/_search
{
  "query": {
    "regexp": {
      "review": {
        "value": ".*laundr.*"
      }
    }
  }
}

字符串

4sup72z8

4sup72z81#

有两种方法可以分析您的查询,两者都是互补的:
A.使用Explain API
B.使用Profile API

相关问题