TERM VS MATCH | |
======================================================================================= | |
Full text queries | |
======================================================================================= | |
FULL TEXT QUERIES USING- e.g | |
match - EACH WORD devops | |
match_phrase - FULL PHRASE devops school | |
match_phrase_prefix | |
======================================================================================= | |
The match keyword | |
======================================================================================= | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match" : { | |
"name" : "webster" | |
} | |
} | |
} | |
' | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match" : { | |
"name" : { | |
"query" : "frank norris", | |
"operator" : "or" | |
} | |
} | |
} | |
} | |
' | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match" : { | |
"name" : { | |
"query" : "frank norris", | |
"operator" : "and" | |
} | |
} | |
} | |
} | |
' | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match" : { | |
"name" : { | |
"query" : "Jeannine Norris", | |
"operator" : "and" | |
} | |
} | |
} | |
} | |
' | |
----DEFAUL OPERATOR IS or | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match" : { | |
"street" : "tompkins place" | |
} | |
} | |
} | |
' | |
======================================================================================= | |
The match_phrase keyword | |
======================================================================================= | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match_phrase" : { | |
"street" : "tompkins place" | |
} | |
} | |
} | |
' | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match_phrase" : { | |
"state" : "puerto rico" | |
} | |
} | |
} | |
' | |
======================================================================================= | |
The match_phrase_prefix | |
======================================================================================= | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match_phrase_prefix" : { | |
"name" : "ma" | |
} | |
} | |
} | |
' | |
curl -XGET 'localhost:9200/customers/_search?pretty' -H 'Content-Type: application/json' -d' | |
{ | |
"query": { | |
"match_phrase_prefix" : { | |
"street" : "clymer st" | |
} | |
} | |
} | |
' | |
Reference
- Sample Data & Query – https://github.com/devopsschool-demo-labs-projects/elasticsearch
I’m a DevOps/SRE/DevSecOps/Cloud Expert passionate about sharing knowledge and experiences. I am working at Cotocus. I blog tech insights at DevOps School, travel stories at Holiday Landmark, stock market tips at Stocks Mantra, health and fitness guidance at My Medic Plus, product reviews at I reviewed , and SEO strategies at Wizbrand.
Please find my social handles as below;
Rajesh Kumar Personal Website
Rajesh Kumar at YOUTUBE
Rajesh Kumar at INSTAGRAM
Rajesh Kumar at X
Rajesh Kumar at FACEBOOK
Rajesh Kumar at LINKEDIN
Rajesh Kumar at PINTEREST
Rajesh Kumar at QUORA
Rajesh Kumar at WIZBRAND