ElasticSearch Query DSL
ES's Query DSL is a language for specifying queries in JSON.
This is by far not an exhaustive documentation, it's just stuff I use the most; see official documentation for more. Especially the boosting and scoring functionality is not documented here to proper extent.
Contents
Queries
match, multi_match
The match queries accept, analyze, and construct query out of text/numeric/date. The match family of queries does not go through a "query parsing" process. It does not support field name prefixes, wildcard characters, or other "advance" features.
Here, message is name of the field to match in (can be also _all):
{
"match" : {
"message" : "this is a test"
}
}
By default, terms are OR'ed; to AND them:
{
"match" : {
"message" : {
"query" : "this is a test",
"operator" : "and"
}
}
}
To match a phrase:
{
"match_phrase" : {
"message" : "this is a test"
}
}
or using the last word as prefix (the "as you type" search):
{
"match_phrase_prefix" : {
"message" : "this is a test"
}
}
To match in multiple fields, with optional boosting, use:
{
"multi_match" : {
"query" : "this is a test",
"fields" : [ "subject^2", "message" ]
}
}
where matches in subject are "twice as important" as matched in message.