首页  

elasticsearch term match match_phrase 区别     所属分类 elasticsearch 浏览量 1324
测试数据
{ "foo":"tiger say hello world to you" }
{ "foo":"Hello world" }
{ "foo":"World Hello" }

PUT foo
POST /foo/_doc
{ "foo":"Hello world" }

...





term 精确匹配


{
    "query":{
        "term":{
            "foo": "hello"
        }
    }
}

{
    "query":{
        "term":{
            "foo": "Hello"
        }
    }
}

{
    "query":{
        "term":{
            "foo": "hello world"
        }
    }
}


{
    "query":{
        "term":{
            "foo": "Hello world"
        }
    }
}


match 模糊匹配  
对输入分词 文档只要包含match查询条件的一部分就会返回

{
    "query":{
        "match":{
            "foo":"hello world"
        }
    }
}

match_phase 
对输入分词,文档必须满足以下条件
包含所有term 且 顺序一致

{
    "query":{
        "match_phrase":{
            "foo":"hello world"
        }
    }
}


querystring 

http://127.0.0.1:9200/foo/_search?q=hello

http://127.0.0.1:9200/foo/_search?q=foo:hello

http://127.0.0.1:9200/foo/_search?q=foo:"hello"

http://127.0.0.1:9200/foo/_search?q=foo:"hello world"

全文检索:直接写要搜索的单词,例如 q=first
单字段的全文检索 q=mesg:first
单字段的精确检索 搜索单词加双引号 q=user:"tiger"
多个检索条件的组合 
   可以使用 NOT, AND 和 OR 来组合检索,注意必须是大写。 
   q=user:("chenlin7" OR "chenlin") AND NOT mesg:first

字段是否存在
   _exists_:user 表示要求 user 字段存在
   _missing_:user 表示要求 user 字段不存在
   
   
通配符  ? 表示单字母,* 表示任意个字母。 fir?t mess*

上一篇     下一篇
银行理财风险等级

HTTP协议中PUT和POST的区别

elasticsearch索引_source index store doc_values 参数实例

postman中form-data x-www-form-urlencoded raw binary的区别

elasticsearch term 和 match

kafka1.1.0无法消费问题