Elasticsearch: Difference between “Term”, “Match Phrase”, and “Query String”

前端 未结 2 653
鱼传尺愫
鱼传尺愫 2020-11-28 18:04

New here to Elasticsearch and trying to get a better understanding on the difference between these queries. As far as I can tell, term matches a single term (ne

2条回答
  •  春和景丽
    2020-11-28 18:21

    I think some one definitely looking for differences between them with respect to PARTIAL SEARCH Here is my analysis with default ‘standard analyzer’ :-

    Suppose ,We have data :-

    { "name" : “Hello”}

    Now what if we want to do partial search with ell ???

    Term Query OR Match query

    {"term":{"name": "*ell*" }
    

    Will not work , return noting .

    {"term":{"name": "*zz* *ell*" }
    

    Will not work , return noting .

    Conclusion - Term or Match is not able to do partial search at all

    wildcard Query :-

    {"wildcard":{"name": "*ell*" }
    

    Will work give result { "name" : "Hello"}

    {"wildcard":{"name": "*zz* *ell*" }
    

    Will not work , return noting .

    Conclusion - wildcard is able to do partial search with one token only

    Query_string :-

    {"query_string": {"default_field": "name","query": "*ell*"}
    

    Will work give result { "name" : “Hello”}

    {"query_string": {"default_field": "name","query": "*zz* *ell*" }
    

    Will work give result { "name" : “Hello”} .

    Conclusion - query_string is able to search with two token are given

    -> here token are ell and zz

提交回复
热议问题