Sample Query with Elasticsearch [6.4]

nami oyamada
Sep 12, 2018 · 2 min read

match

GET /hotel/_search
{
“query”: { “match_all”: {} }
}

term

GET /hotel/_search
{
“query”: { “term”: {“hotel_name” : “Pull man G”} }
}

range

GET /hotel/_search
{
“query”: {
range” : {
“price” : {
gte” : 1000,
lte” : 4000,
“boost” : 2.0
}
}
}
}

bool

POST /hotel/_search
{
“query”: {
bool” : {
“must” : {
“term” : {“hotel_name” : “Pullman” }
},
“filter”: {
“term” : { “tag” : “hotel” }
},
“must_not” : {
“range” : {
“price” : { “gte” : 1000, “lte” : 4000 }
}
},
“should” : [
{ “term” : { “tag” : “breakfast” } }
],
“boost” : 1.0
}
}
}

dis_max

GET /hotel/_search
{
“query”: {
“dis_max” : {
“tie_breaker” : 0.8,
“boost” : 2,
“queries” : [
{
“term” : { “hotel_rang” : 1}
},
{
“term” : { “hotel_rang” : 2}
}
]
}
}
}

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade