zoukankan      html  css  js  c++  java
  • 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

  • 相关阅读:
    redhat下设置网桥br0
    RackSpace推开源云计算平台OpenStack震动业界
    centos5.2 64位yum国内源之首选 上海交大(未验证)
    image config
    编程的四种境界
    怎样学好C语言
    利用SSL加密HTTP通道加强IIS安全性
    Sql Server 日期函数
    如何启用Oracle 11g的默认用户Scott
    ASP.NET自定义错误处理页面的添加
  • 原文地址:https://www.cnblogs.com/qiu-hua/p/14196897.html
Copyright © 2011-2022 走看看