GET /twitter/_search?q=user:kimchy GET /twitter/tweet,user/_search?q=user:kimchy GET /kimchy,elasticsearch/tweet/_search?q=tag:wow GET /_all/tweet/_search?q=tag:wow GET /_search?q=tag:wow
GET twitter/tweet/_search?q=user:kimchy
qhtml
The query string (maps to the query_string query, see Query String Query for more details).api
GET /twitter/tweet/_search { "explain": true, "version": true, "query" : { "term" : { "user" : "kimchy" } }, "from" : 0, "size" : 10, "sort" : [ { "post_date" : {"order" : "asc"}}, "user", { "name" : "desc" }, { "age" : "desc" }, "_score" ], "_source": [ "obj1.*", "obj2.*" ], "script_fields" : { "test1" : { "script" : "params['_source']['message']" } }, "post_filter": { "term": { "color": "red" } }, "highlight" : { "pre_tags" : ["<tag1>", "<tag2>"], "post_tags" : ["</tag1>", "</tag2>"], "fields" : { "_all" : {} } } }
標準全文查詢elasticsearch
GET /_search { "query": { "match" : { "message" : "this is a test" } } }
短語查詢,支持分詞ide
GET /_search { "query": { "match_phrase" : { "message" : { "query" : "this is a test", "analyzer" : "my_analyzer" } } } }
GET /_search { "query": { "match_phrase_prefix" : { "message" : { "query" : "quick brown f", "max_expansions" : 10 } } } }
支持多字段版本post
GET /_search { "query": { "multi_match" : { "query" : "this is a test", "fields" : [ "subject^3", "message" ] } } }
中止符(stopwords)ui
GET /_search { "query": { "common": { "body": { "query": "this is bonsai cool", "cutoff_frequency": 0.001 } } } }
查詢解析this
GET /_search { "query": { "query_string" : { "default_field" : "content", "query" : "this AND that OR thus" } } }
使用 SimpleQueryParser去解析查詢語句code
GET /_search { "query": { "simple_query_string" : { "query": "\"fried eggs\" +(eggplant | potato) -frittata", "analyzer": "snowball", "fields": ["body^5","_all"], "default_operator": "and" } } }
更底層的查詢regexp
idshtm
GET /_search
{
"query": {
"constant_score" : {
"filter" : {
"terms" : { "user" : ["kimchy", "elasticsearch"]}
}
}
}
}
indices
GET /_search
{
"query": {
"constant_score" : {
"filter" : {
"term" : { "user" : "kimchy"}
},
"boost" : 1.2
}
}
}
Parent Id
GET /_search { "query": { "constant_score" : { "filter" : { "term" : { "user" : "kimchy"} }, "boost" : 1.2 } } }