• ES基础(二十一) 单字符串多字段查询:Multi Match


     

     

     

     

     

    POST blogs/_search
    {
        "query": {
            "dis_max": {
                "queries": [
                    { "match": { "title": "Quick pets" }},
                    { "match": { "body":  "Quick pets" }}
                ],
                "tie_breaker": 0.2
            }
        }
    }
    
    POST blogs/_search
    {
      "query": {
        "multi_match": {
          "type": "best_fields",
          "query": "Quick pets",
          "fields": ["title","body"],
          "tie_breaker": 0.2,
          "minimum_should_match": "20%"
        }
      }
    }
    
    
    
    POST books/_search
    {
        "multi_match": {
            "query":  "Quick brown fox",
            "fields": "*_title"
        }
    }
    
    
    POST books/_search
    {
        "multi_match": {
            "query":  "Quick brown fox",
            "fields": [ "*_title", "chapter_title^2" ]
        }
    }
    
    
    
    DELETE /titles
    PUT /titles
    {
        "settings": { "number_of_shards": 1 },
        "mappings": {
            "my_type": {
                "properties": {
                    "title": {
                        "type":     "string",
                        "analyzer": "english",
                        "fields": {
                            "std":   {
                                "type":     "string",
                                "analyzer": "standard"
                            }
                        }
                    }
                }
            }
        }
    }
    
    PUT /titles
    {
      "mappings": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "english"
          }
        }
      }
    }
    
    POST titles/_bulk
    { "index": { "_id": 1 }}
    { "title": "My dog barks" }
    { "index": { "_id": 2 }}
    { "title": "I see a lot of barking dogs on the road " }
    
    
    GET titles/_search
    {
      "query": {
        "match": {
          "title": "barking dogs"
        }
      }
    }
    
    DELETE /titles
    PUT /titles
    {
      "mappings": {
        "properties": {
          "title": {
            "type": "text",
            "analyzer": "english",
            "fields": {"std": {"type": "text","analyzer": "standard"}}
          }
        }
      }
    }
    
    POST titles/_bulk
    { "index": { "_id": 1 }}
    { "title": "My dog barks" }
    { "index": { "_id": 2 }}
    { "title": "I see a lot of barking dogs on the road " }
    
    GET /titles/_search
    {
       "query": {
            "multi_match": {
                "query":  "barking dogs",
                "type":   "most_fields",
                "fields": [ "title", "title.std" ]
            }
        }
    }
    
    GET /titles/_search
    {
       "query": {
            "multi_match": {
                "query":  "barking dogs",
                "type":   "most_fields",
                "fields": [ "title^10", "title.std" ]
            }
        }
    }

    本文来自博客园,作者:秋华,转载请注明原文链接:https://www.cnblogs.com/qiu-hua/p/14196897.html

  • 相关阅读:
    web自动化测试---自动化脚本设置百度搜索每页显示条数
    web自动化测试---测试中其他一些常用操作
    web自动化测试---css方式定位页面元素
    web自动化测试---xpath方式定位页面元素
    linux系统 之 curl命令
    http协议
    php编程 之 php基础二
    shell编程 之 ssh远程连接
    php编程 之 php进阶练习
    php编程 之 php基础一
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196897.html
Copyright © 2020-2023  润新知