Elasticsearch 核心技术(八):常用 DSL 查询(全文搜索、精确匹配、布尔查询)

在这里插入图片描述

❤️ 博客主页:水滴技术
🚀 支持水滴:点赞👍 + 收藏⭐ + 留言💬
🌸 订阅专栏:大数据核心技术从入门到精通

文章目录

  • 一、全文搜索
    • 1.1 查询所有(match_all)
    • 1.2 全文检索(match)
    • 1.3 多字段全文检索(multi_match)
  • 二、精确匹配
    • 2.1 精确查询(term)
    • 2.2 精确查询(terms)
    • 2.3 主键查询(ids)
    • 2.4 范围查询(range)
  • 三、布尔查询(bool)
    • 3.1 必须匹配(must)
    • 3.2 可以匹配(should)
    • 3.3 不匹配(must_not)
    • 3.4 过滤器(filter)
  • 附录
    • 附录一:mt_product 索引 demo 脚本
    • 附录二:mt_product 数据 demo 脚本
  • 系列文章
  • 热门专栏


大家好,我是水滴~~

Elasticsearch 提供了一个完整的基于 JSON 的 DSL(Domain Specific Language,领域特定语言) 查询语言,它非常的丰富和灵活,并支持构建更加复杂和健壮的查询。

本篇我们主要讲述常用的三种 DSL 查询:全文搜索、精确匹配、布尔查询。

一、全文搜索

全文搜索是 Elasticsearch 的核心功能,在创建索引时要将字段映射设为 text 类型,并可指定分词器,我们方可使用该功能。关于数据类型和分词器可以参考之前的一些文章,这里不再赘述。

1.1 查询所有(match_all)

可以使用 match_all 来查询指定索引下的所有文档,下面例子查询“my_product”字段中所有文档:

GET /mt_product/_search
{
  "query": {
    "match_all": {}
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 12,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "name" : "招牌海苔单人餐",
          "tags" : [
            "寿司"
          ],
          "price" : 9.9,
          "sales" : 1000,
          "score" : 4.7,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:01:00"
        }
      },
      ...
    ]
  }
}

1.2 全文检索(match)

可以使用 match 进行全文搜索匹配(类似于 SQL 中的 like %%),搜索的字段类型要是 text 类型才能生效。下例中搜索"my_product"索引,搜索字段使用 “name”:

GET /mt_product/_search
{
  "query": {
    "match": {
      "name": "好吃的寿司"
    }
  }
}

响应:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.7955686,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.7955686,
        "_source" : {
          "id" : 3,
          "name" : "三文鱼寿司",
          "tags" : [
            "寿司,鱼肉"
          ],
          "price" : 16.9,
          "sales" : 820,
          "score" : 4.9,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:03:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 1.6760855,
        "_source" : {
          "id" : 4,
          "name" : "极上全品寿司套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 25,
          "sales" : 1500,
          "score" : 4.6,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:04:00"
        }
      }
    ]
  }
}

1.3 多字段全文检索(multi_match)

有的时候同一个搜索请求,要应用到多个字段上,那么使用 multi_match 即可实现,如下例:

GET /mt_product/_search
{
  "query": {
    "multi_match": {
      "query": "好吃的寿司",
      "fields": ["name", "store_name"]
    }
  }
}

响应:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.7955686,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.7955686,
        "_source" : {
          "id" : 3,
          "name" : "三文鱼寿司",
          "tags" : [
            "寿司,鱼肉"
          ],
          "price" : 16.9,
          "sales" : 820,
          "score" : 4.9,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:03:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 1.6760855,
        "_source" : {
          "id" : 4,
          "name" : "极上全品寿司套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 25,
          "sales" : 1500,
          "score" : 4.6,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:04:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 0.84174097,
        "_source" : {
          "id" : 1,
          "name" : "招牌海苔单人餐",
          "tags" : [
            "寿司"
          ],
          "price" : 9.9,
          "sales" : 1000,
          "score" : 4.7,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:01:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 0.84174097,
        "_source" : {
          "id" : 2,
          "name" : "1-2人招牌双拼套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 18.9,
          "sales" : 1200,
          "score" : 4.8,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:02:00"
        }
      }
    ]
  }
}

二、精确匹配

精确匹配应用查找结构化的数据,一般使用 keyword 类型,应避免使用 text 类型。

2.1 精确查询(term)

根据精确值进行查询,类似于 SQL 中的 = ,示例:


GET /mt_product/_search
{
  "query": {
    "term": {
      "store_id": {
        "value": "1"
      }
    }
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.6486585,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.6486585,
        "_source" : {
          "id" : 1,
          "name" : "招牌海苔单人餐",
          "tags" : [
            "寿司"
          ],
          "price" : 9.9,
          "sales" : 1000,
          "score" : 4.7,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:01:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.6486585,
        "_source" : {
          "id" : 2,
          "name" : "1-2人招牌双拼套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 18.9,
          "sales" : 1200,
          "score" : 4.8,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:02:00"
        }
      }
    ]
  }
}

2.2 精确查询(terms)

terms 可以匹配多个值,类似于 SQL 中的 in(...),示例:

GET /mt_product/_search
{
  "query": {
    "terms": {
      "store_id": [1, 2]
    }
  }
}

响应结果:

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 1.0,
        "_source" : {
          "id" : 1,
          "name" : "招牌海苔单人餐",
          "tags" : [
            "寿司"
          ],
          "price" : 9.9,
          "sales" : 1000,
          "score" : 4.7,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:01:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "id" : 2,
          "name" : "1-2人招牌双拼套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 18.9,
          "sales" : 1200,
          "score" : 4.8,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:02:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "id" : 3,
          "name" : "三文鱼寿司",
          "tags" : [
            "寿司,鱼肉"
          ],
          "price" : 16.9,
          "sales" : 820,
          "score" : 4.9,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:03:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "4",
        "_score" : 1.0,
        "_source" : {
          "id" : 4,
          "name" : "极上全品寿司套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 25,
          "sales" : 1500,
          "score" : 4.6,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:04:00"
        }
      }
    ]
  }
}

2.3 主键查询(ids)

根据多个主键查询,类似于 SQL 中的 id in (...),示例:

GET /mt_product/_search
{
  "query": {
    "ids": {
      "values": [10, 11]
    }
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "10",
        "_score" : 1.0,
        "_source" : {
          "id" : 10,
          "name" : "双层原味板烧鸡腿麦满分四件套",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 29,
          "sales" : 3000,
          "score" : 4.8,
          "store_id" : 5,
          "store_name" : "麦当劳",
          "create_time" : "2023-01-18 08:10:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "11",
        "_score" : 1.0,
        "_source" : {
          "id" : 11,
          "name" : "火腿扒麦满分组合",
          "tags" : [
            "汉堡"
          ],
          "price" : 8,
          "sales" : 100000,
          "score" : 4.9,
          "store_id" : 5,
          "store_name" : "麦当劳",
          "create_time" : "2023-01-18 08:11:00"
        }
      }
    ]
  }
}

2.4 范围查询(range)

查找一个范围,类似于 SQL 中的 ><,示例:

GET /mt_product/_search
{
  "query": {
    "range": {
      "price": {
        "gte": 10,
        "lte": 20
      }
    }
  }
}

响应结果:

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 3,
      "relation" : "eq"
    },
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "2",
        "_score" : 1.0,
        "_source" : {
          "id" : 2,
          "name" : "1-2人招牌双拼套餐",
          "tags" : [
            "寿司"
          ],
          "price" : 18.9,
          "sales" : 1200,
          "score" : 4.8,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:02:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.0,
        "_source" : {
          "id" : 3,
          "name" : "三文鱼寿司",
          "tags" : [
            "寿司,鱼肉"
          ],
          "price" : 16.9,
          "sales" : 820,
          "score" : 4.9,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:03:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 1.0,
        "_source" : {
          "id" : 9,
          "name" : "霸道小酥鸡+薯霸王",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 19,
          "sales" : 300,
          "score" : 4.2,
          "store_id" : 4,
          "store_name" : "汉堡王",
          "create_time" : "2023-01-18 08:09:00"
        }
      }
    ]
  }
}

三、布尔查询(bool)

布尔查询就是一个或多个子句的组合,每一个子句都是一个子查询,根据组合的方式可分为下面几种类型:

  • must:必须匹配每个子句,类似于 SQL 中的 and,参与评分。
  • should:可以匹配任意子句,类似于 SQL 中的 or,参与评分。
  • must_not:必须不匹配每个子类,类似于 SQL中的 not in,不参与评分。
  • filter:过滤上下文,它与 must 的不同之处是不会影响匹配文档的分数。

3.1 必须匹配(must)

我们要查询 tag 为“寿司”,并且价格小于等于 15 块钱,就可以使用这样:

GET /mt_product/_search
{
  "query": {
    "bool": {
      "must": [
        {
          "match": {
            "tags": "寿司"
          }
        },{
          "range": {
            "price": {
              "lte": 15
            }
          }
        }
      ]
    }
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 1,
      "relation" : "eq"
    },
    "max_score" : 2.228378,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "1",
        "_score" : 2.228378,
        "_source" : {
          "id" : 1,
          "name" : "招牌海苔单人餐",
          "tags" : [
            "寿司"
          ],
          "price" : 9.9,
          "sales" : 1000,
          "score" : 4.7,
          "store_id" : 1,
          "store_name" : "M多寿司",
          "create_time" : "2023-01-18 08:01:00"
        }
      }
    ]
  }
}

3.2 可以匹配(should)

查询 tag 为“鱼肉”,或者 store_name 为“麦当劳”,可以这样查询:

GET /mt_product/_search
{
  "query": {
    "bool": {
      "should": [
        {
          "match": {
            "tags": "鱼肉"
          }
        },{
          "match": {
            "store_name": "麦当劳"
          }
        }
      ]
    }
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 4,
      "relation" : "eq"
    },
    "max_score" : 1.9003463,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "3",
        "_score" : 1.9003463,
        "_source" : {
          "id" : 3,
          "name" : "三文鱼寿司",
          "tags" : [
            "寿司,鱼肉"
          ],
          "price" : 16.9,
          "sales" : 820,
          "score" : 4.9,
          "store_id" : 2,
          "store_name" : "爱食寿司",
          "create_time" : "2023-01-18 08:03:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "10",
        "_score" : 1.6119244,
        "_source" : {
          "id" : 10,
          "name" : "双层原味板烧鸡腿麦满分四件套",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 29,
          "sales" : 3000,
          "score" : 4.8,
          "store_id" : 5,
          "store_name" : "麦当劳",
          "create_time" : "2023-01-18 08:10:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "11",
        "_score" : 1.6119244,
        "_source" : {
          "id" : 11,
          "name" : "火腿扒麦满分组合",
          "tags" : [
            "汉堡"
          ],
          "price" : 8,
          "sales" : 100000,
          "score" : 4.9,
          "store_id" : 5,
          "store_name" : "麦当劳",
          "create_time" : "2023-01-18 08:11:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "12",
        "_score" : 1.6119244,
        "_source" : {
          "id" : 12,
          "name" : "原味板烧鸡腿麦满组件",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 9.9,
          "sales" : 140000,
          "score" : 4.9,
          "store_id" : 5,
          "store_name" : "麦当劳",
          "create_time" : "2023-01-18 08:12:00"
        }
      }
    ]
  }
}

3.3 不匹配(must_not)

查询 store_name 不是“麦当劳”,并且 tags 不包含“寿司”,可以这样查询:

GET /mt_product/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "match": {
            "store_name": "麦当劳"
          }
        },{
          "match": {
            "tags": "寿司"
          }
        }
      ]
    }
  }
}

响应结果:

{
  "took" : 0,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 5,
      "relation" : "eq"
    },
    "max_score" : 0.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "5",
        "_score" : 0.0,
        "_source" : {
          "id" : 5,
          "name" : "劲脆鸡腿汉堡",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 21.5,
          "sales" : 200,
          "score" : 4.5,
          "store_id" : 3,
          "store_name" : "肯德基",
          "create_time" : "2023-01-18 08:05:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "6",
        "_score" : 0.0,
        "_source" : {
          "id" : 6,
          "name" : "香辣鸡腿汉堡",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 21.5,
          "sales" : 98,
          "score" : 4.4,
          "store_id" : 3,
          "store_name" : "肯德基",
          "create_time" : "2023-01-18 08:06:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "7",
        "_score" : 0.0,
        "_source" : {
          "id" : 7,
          "name" : "20块香辣鸡翅",
          "tags" : [
            "鸡肉"
          ],
          "price" : 99,
          "sales" : 5,
          "score" : 4.8,
          "store_id" : 3,
          "store_name" : "肯德基",
          "create_time" : "2023-01-18 08:07:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "8",
        "_score" : 0.0,
        "_source" : {
          "id" : 8,
          "name" : "3层芝士年堡套餐",
          "tags" : [
            "汉堡"
          ],
          "price" : 29,
          "sales" : 4000,
          "score" : 4.9,
          "store_id" : 4,
          "store_name" : "汉堡王",
          "create_time" : "2023-01-18 08:08:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 0.0,
        "_source" : {
          "id" : 9,
          "name" : "霸道小酥鸡+薯霸王",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 19,
          "sales" : 300,
          "score" : 4.2,
          "store_id" : 4,
          "store_name" : "汉堡王",
          "create_time" : "2023-01-18 08:09:00"
        }
      }
    ]
  }
}

3.4 过滤器(filter)

filter 过滤的结果不会影响原查询的得分。比如我们在上一条查询的基础上,增加 store_name 为“汉堡王”,其查询结果的得分,与上一条查询的得分是一样的。

GET /mt_product/_search
{
  "query": {
    "bool": {
      "must_not": [
        {
          "match": {
            "store_name": "麦当劳"
          }
        },{
          "match": {
            "tags": "寿司"
          }
        }
      ], 
      "filter": [
        {
          "match": {
            "store_name": "汉堡王"
          }
        }
      ]
    }
  }
}

响应结果:

{
  "took" : 6,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : {
      "value" : 2,
      "relation" : "eq"
    },
    "max_score" : 0.0,
    "hits" : [
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "8",
        "_score" : 0.0,
        "_source" : {
          "id" : 8,
          "name" : "3层芝士年堡套餐",
          "tags" : [
            "汉堡"
          ],
          "price" : 29,
          "sales" : 4000,
          "score" : 4.9,
          "store_id" : 4,
          "store_name" : "汉堡王",
          "create_time" : "2023-01-18 08:08:00"
        }
      },
      {
        "_index" : "mt_product",
        "_type" : "_doc",
        "_id" : "9",
        "_score" : 0.0,
        "_source" : {
          "id" : 9,
          "name" : "霸道小酥鸡+薯霸王",
          "tags" : [
            "汉堡,鸡肉"
          ],
          "price" : 19,
          "sales" : 300,
          "score" : 4.2,
          "store_id" : 4,
          "store_name" : "汉堡王",
          "create_time" : "2023-01-18 08:09:00"
        }
      }
    ]
  }
}

附录

附录一:mt_product 索引 demo 脚本

PUT mt_product
{
  "mappings": {
    "properties": {
      "id": {
        "type": "long"
      },
      "name": {
        "type": "text",
        "analyzer": "ik_max_word"
      },
      "tags": {
        "type":  "text",
        "analyzer": "ik_max_word"
      },
      "price": {
        "type": "float"
      },
      "sales": {
        "type": "integer"
      },
      "score": {
        "type": "float"
      },
      "store_id": {
        "type": "keyword"
      },
      "store_name": {
        "type": "text",
        "analyzer": "ik_max_word"
      },
      "create_time": {
        "type": "date"
      }
    }
  }
}

附录二:mt_product 数据 demo 脚本

POST /mt_product/_doc/1
{
  "id": 1,
  "name": "招牌海苔单人餐",
  "tags": ["寿司"],
  "price": 9.9,
  "sales": 1000,
  "score": 4.7,
  "store_id": 1,
  "store_name": "M多寿司",
  "create_time": "2023-01-18 08:01:00"
}

POST /mt_product/_doc/2
{
  "id": 2,
  "name": "1-2人招牌双拼套餐",
  "tags": ["寿司"],
  "price": 18.9,
  "sales": 1200,
  "score": 4.8,
  "store_id": 1,
  "store_name": "M多寿司",
  "create_time": "2023-01-18 08:02:00"
}

POST /mt_product/_doc/3
{
  "id": 3,
  "name": "三文鱼寿司",
  "tags": ["寿司,鱼肉"],
  "price": 16.9,
  "sales": 820,
  "score": 4.9,
  "store_id": 2,
  "store_name": "爱食寿司",
  "create_time": "2023-01-18 08:03:00"
}

POST /mt_product/_doc/4
{
  "id": 4,
  "name": "极上全品寿司套餐",
  "tags": ["寿司"],
  "price": 25,
  "sales": 1500,
  "score": 4.6,
  "store_id": 2,
  "store_name": "爱食寿司",
  "create_time": "2023-01-18 08:04:00"
}

POST /mt_product/_doc/5
{
  "id": 5,
  "name": "劲脆鸡腿汉堡",
  "tags": ["汉堡,鸡肉"],
  "price": 21.5,
  "sales": 200,
  "score": 4.5,
  "store_id": 3,
  "store_name": "肯德基",
  "create_time": "2023-01-18 08:05:00"
}

POST /mt_product/_doc/6
{
  "id": 6,
  "name": "香辣鸡腿汉堡",
  "tags": ["汉堡,鸡肉"],
  "price": 21.5,
  "sales": 98,
  "score": 4.4,
  "store_id": 3,
  "store_name": "肯德基",
  "create_time": "2023-01-18 08:06:00"
}

POST /mt_product/_doc/7
{
  "id": 7,
  "name": "20块香辣鸡翅",
  "tags": ["鸡肉"],
  "price": 99,
  "sales": 5,
  "score": 4.8,
  "store_id": 3,
  "store_name": "肯德基",
  "create_time": "2023-01-18 08:07:00"
}

POST /mt_product/_doc/8
{
  "id": 8,
  "name": "3层芝士年堡套餐",
  "tags": ["汉堡"],
  "price": 29,
  "sales": 4000,
  "score": 4.9,
  "store_id": 4,
  "store_name": "汉堡王",
  "create_time": "2023-01-18 08:08:00"
}

POST /mt_product/_doc/9
{
  "id": 9,
  "name": "霸道小酥鸡+薯霸王",
  "tags": ["汉堡,鸡肉"],
  "price": 19,
  "sales": 300,
  "score": 4.2,
  "store_id": 4,
  "store_name": "汉堡王",
  "create_time": "2023-01-18 08:09:00"
}

POST /mt_product/_doc/10
{
  "id": 10,
  "name": "双层原味板烧鸡腿麦满分四件套",
  "tags": ["汉堡,鸡肉"],
  "price": 29,
  "sales": 3000,
  "score": 4.8,
  "store_id": 5,
  "store_name": "麦当劳",
  "create_time": "2023-01-18 08:10:00"
}

POST /mt_product/_doc/11
{
  "id": 11,
  "name": "火腿扒麦满分组合",
  "tags": ["汉堡"],
  "price": 8,
  "sales": 100000,
  "score": 4.9,
  "store_id": 5,
  "store_name": "麦当劳",
  "create_time": "2023-01-18 08:11:00"
}

POST /mt_product/_doc/12
{
  "id": 12,
  "name": "原味板烧鸡腿麦满组件",
  "tags": ["汉堡,鸡肉"],
  "price": 9.9,
  "sales": 140000,
  "score": 4.9,
  "store_id": 5,
  "store_name": "麦当劳",
  "create_time": "2023-01-18 08:12:00"
}

系列文章

🔥 Elasticsearch 核心技术(一):Elasticsearch 安装、配置、运行(Windows 版)
🔥 Elasticsearch 核心技术(二):elasticsearch-head 插件安装和使用
🔥 Elasticsearch 核心技术(三):Kibana 安装、配置、运行(Windows 版)
🔥 Elasticsearch 核心技术(四):索引管理、映射管理、文档管理(REST API)
🔥 Elasticsearch 核心技术(五):常用数据类型详解
🔥 Elasticsearch 核心技术(六):内置的 8 种分词器详解 + 代码示例
🔥 Elasticsearch 核心技术(七):IK 中文分词器的安装、使用、自定义字典

热门专栏

👍 《Python入门核心技术》
👍 《IDEA 教程:从入门到精通》
👍 《Java 教程:从入门到精通》
👍 《MySQL 教程:从入门到精通》
👍 《大数据核心技术从入门到精通》

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mfbz.cn/a/4022.html

如若内容造成侵权/违法违规/事实不符,请联系我们进行投诉反馈qq邮箱809451989@qq.com,一经查实,立即删除!

相关文章

CS-Stdio Display Builder

Display Builder 1) 操作界面编辑器和Runtime 2&#xff09;在EPICS edd/dm, medm, edm, ...想法上构建 3&#xff09;与CS-Studio BOY兼容性非常好 4&#xff09;大约2015年在CS-Stdio/Eclipse中开始&#xff0c;现在在CS-Studio/Phoebus中 5) 从209年以Web Runtime获取。…

logstash+elasticsearch+Kibana(ELK)日志收集

文章目录一.安装elasticsearch二. 安装kibana三.配置logstash四.springboot整合logstash五.spring整合Elastic Search不要一股脑执行以下语句,请观察修改要修改的地方 注意给logstash,elasticsearch,kibana释放端口,云服务器提供商和系统的端口 一.安装elasticsearch # 安装e…

【Linux】共享内存

1.共享内存的概念共享内存区是最快的IPC形式。一旦这样的内存映射到共享它的进程的地址空间&#xff0c;这些进程间数据传递不再涉及到内核&#xff0c;换句话说是进程不再通过执行进入内核的系统调用来传递彼此的数据。通信的前提是让两个进程看到同一份资源&#xff0c;信息的…

Multisim14.3安装包下载及安装教程

[软件大小]: 888 MB [安装环境]: Win11/Win 10 [软件安装包下载]:https://pan.quark.cn/s/1c0217caf24a Multisim是美国国家仪器&#xff08;NI&#xff09;有限公司推出的以Windows为基础的仿真工具&#xff0c;适用于板级的模拟/数字电路板的设计工作 安装步骤 1.选中下载好…

自主AI能力加速企业智能化转型 | 爱分析报告

报告编委 黄勇 爱分析合伙人&首席分析师 孟晨静 爱分析分析师 外部专家&#xff08;按姓氏拼音排序&#xff09; 杜晨阳 力维智联 五维实验室主任 王哲 九章云极DataCanvas 雅图BU总经理 特别鸣谢&#xff08;按拼音排序&#xff09; 目录 1. 报告综述 2. 金融…

Java 3个常用工作流引擎

一&#xff1a;Java工作流框架是一种用于设计、执行和管理工作流程的技术。以下是几个常见的Java工作流框架&#xff1a; Activiti&#xff1a;Activiti是一款流行的开源Java工作流引擎&#xff0c;它基于BPMN 2.0标准&#xff0c;支持复杂的工作流程设计和管理。Activiti具有高…

Centos7 XFS(dm-0):Internal error XFS_WANT_CORRUPTED_GOTO

在k8s的道路上我们都是小白&#xff0c;每天启动虚机都会遇到各种各样的问题&#xff0c;这不 部署的k8s虚机启动发现操作系统启动异常&#xff0c;提示如下报错信息 XFS&#xff08;dm-0&#xff09;:Internal error XFS_WANT_CORRUPTED_GOTO at line 1700 of file fs/xfs/l…

【周末闲谈】文心一言,模仿还是超越?

个人主页&#xff1a;【&#x1f60a;个人主页】 系列专栏&#xff1a;【❤️周末闲谈】 周末闲谈 ✨第一周 二进制VS三进制 文章目录周末闲谈前言一、背景环境二、文心一言&#xff1f;(_)?三、文心一言的优势&#xff1f;&#x1f617;&#x1f617;&#x1f617;四、文心一…

ADC选型关注的参数

目前&#xff0c;用来量化ADC动态性能的六个技术指标分别为SINAD&#xff08;信号与噪声失真比&#xff09;&#xff0c;ENOB&#xff08;有效位数&#xff09;&#xff0c;SNR&#xff08;信噪比&#xff09;&#xff0c;THD&#xff08;总谐波失真&#xff09;&#xff0c;TH…

ChatGPT原理解析

文章目录Transformer模型结构构成组件整体流程GPT预训练微调模型GPT2GPT3局限性GPT4相关论文Transformer Transformer&#xff0c;这是一种仅依赖于注意力机制而不使用循环或卷积的简单模型&#xff0c;它简单而有效&#xff0c;并且在性能方面表现出色。 在时序模型中&#…

GPT-4 介绍

1 简介 本文根据openAI的2023年3月的《GPT-4 Technical Report 》翻译总结的。 原文地址&#xff1a;https://arxiv.org/pdf/2303.08774.pdf 原文确实没有GPT-4 具体的模型结构&#xff0c;openAI向盈利组织、非公开方向发展了。也没透露硬件、训练成本、训练数据、训练方法等…

原生获取DOM节点

目录 一、通过document顶层方法获取 1、获取html标签 2、获取head标签 3、获取body标签 二、getElementBy系列获取 1、ID获取 2、类名获取 3、name属性获取 4、标签名获取 三、query系列获取 1、通过query选择器获取一个元素 2、通过querry选择器获取一组元素 四、通过…

特斯拉的操作系统是用什么语言编写的?

总目录链接>> AutoSAR入门和实战系列总目录 文章目录特斯拉车辆操作系统特斯拉GitHub中使用的语言Ruby和GoPythonSwift 和 Objective CQt我们知道操作系统至少需要一些非常低级的代码&#xff0c;这些代码在系统首次启动时运行&#xff0c;必须使用接近硬件的语言编写。…

如何使用python删除一个文件?好用到上头.....

人生苦短&#xff0c;我用python 若想利用python删除windows里的文件&#xff0c; 这里需要使用os模块 那接下来就看看利用os模块是如何删除文件的吧~ 具体实现方法如下&#xff01; 更多学习资料:点击此处跳转文末名片获取 os.remove(path) 删除文件 path. 如果path是一…

硬件语言Verilog HDL牛客刷题day02 组合逻辑部分

1.VL11 4位数值比较器电路 1.题目&#xff1a; 某4位数值比较器的功能表如下。请用Verilog语言采用门级描述方式&#xff0c;实现此4位数值比较器。 2.解题代码&#xff1a; timescale 1ns/1nsmodule comparator_4(input [3:0] A ,input [3:0] B ,output …

Cortex-A7常用汇编指令

Cortex-A7常用汇编指令 本节我们将介绍一些常用的 Cortex-A7汇编指令&#xff0c;如果想系统的了解 Cortex-A7的所有汇 编指令请参考《 ARM ArchitectureReference Manual ARMv7-A and ARMv7-R edition.pdf》的 A4章节。 处理器内部数据传输指令 使用处理器做的最多事情就是…

黑马点评笔记(自用)

1.优惠卷秒杀 &#xff08;1&#xff09;全局唯一ID 订单如果用自增&#xff0c;容易被猜到交易量&#xff0c;且数据量大的话分成多个表&#xff0c;都是自增&#xff0c;容易出现重复。所以用全局ID生成器&#xff0c;Redis独立自增不会重复&#xff0c;但安全性不保证&#…

Vue Nginx 配置跨域

1、方案1&#xff1a;Nginx配置跨域&#xff0c;Vue不用配置vite代理 1.nginx 配置SSL证书 listen *:443;server_name gitlab.xxxxxx.com;server_tokens off; ## Dont show the nginx version number, a security best practicessl on;ssl_certificate /etc/gitlab/xxxxxx.c…

俺的面试qwq

1.JavaScript的基本数据类型都有什么? 布尔型、数值型、字符串、数组、null、undefined、object、symbol 2.数组方法pop()push() unshift() shift()的作用? pop()删除最后一个元素、push()在数组最后增加元素、unshift()在数组最前面增加元素、shift()删除第一个元素 3.box-s…

【ChatGPTAIGC研讨社】“iPhone时刻”:未来已来

文章目录前言一、ChaGPT&AIGC研讨社简介二、ChatGPT&AIGC研讨社的优势1.丰富充实的资料库Github开源&#xff1a;[ChatGPT_Project](https://github.com/shawshany/ChatGPT_Project)飞书资料库2.重量级嘉宾3.工作机会4.投资资源总结前言 去年年末&#xff0c;ChatGPT以…