• Elasticsearch 认证模拟题 - 21


    一、题目

    写一个查询,要求查询 kibana_sample_data_ecommerce 索引,且 day_of_weekcustomer_gendercurrencytype 这 4 个字段中至少两个以上。

    1.1 考点
    1. Boolean
    1.2 答案
    GET kibana_sample_data_ecommerce/_search
    {
      "query": {
        "bool": {
          "should": [
            {
              "term": {
                "day_of_week": {
                  "value": "Monday"
                }
              }
            },
            {
              "term": {
                "customer_gender": {
                  "value": "MALE"
                }
              }
            },
            {
              "term": {
                "currency": {
                  "value": "EUR"
                }
              }
            },
            {
              "term": {
                "type": {
                  "value": "order"
                }
              }
            }
          ],
          "minimum_should_match": 2
        }
      }
    }
    

    二、题目

    task 索引中文档的 fieldafieldbfieldc 字段进行查询,并
    要求最终的算分是fieldafieldbfieldc 字段上算分的总和,同时要求对 fieldb 字段设置 boosting

    # 创建符合条件的 task 索引,设置 field 字段,并写入数据
    PUT task
    {
      "mappings": {
        "properties": {
          "fielda":{
            "type": "text"
          },
          "fieldb":{
            "type": "text"
          },
          "fieldc":{
            "type": "text"
          },
          "fieldd":{
            "type": "long"
          }
        }
      }
    }
    
    # 写入数据
    POST task/_bulk
    {"index":{}}
    {"fielda":"中国人民广场", "fieldb":"天安门", "fieldc":"中国人民广场", "fieldd": 5}
    {"index":{}}
    {"fielda":"中华人民共和国万岁", "fieldb":"日月潭", "fieldc":"中国人民广场", "fieldd": 6}
    {"index":{}}
    {"fielda":"山上山下红旗飘飘", "fieldb":"农民翻身把歌唱", "fieldc":"中国人民广场", "fieldd": 4}
    {"index":{}}
    {"fielda":"中国共产党万岁", "fieldb":"中国人民广场", "fieldc":"中国人民广场", "fieldd": 5}
    {"index":{}}
    {"fielda":"春眠不觉晓", "fieldb":"中国人民", "fieldc":"处处闻啼鸟", "fieldd": 5}
    
    2.1 考点
    1. Multi-match
    2.2 答案
    GET task/_search
    {
      "query": {
        "multi_match" : {
          "query" : "中华人民",
          "fields" : [ "fielda", "fieldb^2", "fieldc"] 
        }
      }
    }
    

    在这里插入图片描述

    这里更新一个 分数的计算方式

    GET task/_search
    {
      "query": {
        "multi_match" : {
          "query" : "中华人民",
          "fields" : [ "fielda", "fieldb^2", "fieldc"],
          "type": "most_fields"
        }
      }
    }
    

    在这里插入图片描述

  • 相关阅读:
    JS中ajax的原理是什么?
    java-php-python-ssm校园约自习网站计算机毕业设计
    在Jeston NX上部署运行PaddleOCR教程(安装whl包方法)
    c语言范例实例
    【C++】类和对象(中)
    基于Echarts实现可视化数据大屏物流云大数据看板页面HTML模板
    Stream流操作
    软件加密系统Themida应用程序保护指南(八):额外的选择
    Win10常用快捷键
    论文阅读 (63):Get To The Point: Summarization with Pointer-Generator Networks
  • 原文地址:https://blog.csdn.net/Wolf_xujie/article/details/139657836