精準(zhǔn)匹配:
match_phrasedsl = { "query": { "bool": { "must": [ {"match_phrase": { "players.role": "tenderer_winner" }} ] } }}
多條件查詢
current_triplet_dsl =
{"query": {
"bool": {
"must": [
{"term":{"company": company}},
{"term":{"client":common_client}}]}}}
多range條件查詢
{"query":{"bool":{"must":[{"range":{"org_count":{"gte":1}}},{"range":{"sum_count":{"gte":2}}}]}}}
groupby 聚合操作
{"query":{"match_all":{}},"aggs":{"group_by_key":{"terms":{"field":"field","size":100}}}}
如果field類型是text,記得用field.keyword
模糊查詢
{"query":{"wildcard":{"name":"*銀行*"}}}
數(shù)組length長度查詢
{"query":{"script":{"script":"doc['timedelta'].size() >= 6"}}}
index 重命名
{"source":{"index":"prophet_filtered_org_pair_res_20220310"},"dest":{"index":"prophet_filtered_org_to_field_pair_res_20220310"}}
查看某一字段存在的結(jié)果
{"query":{"bool":{"must_not":{"exists":{"field":"pre"}}}}}
以某數(shù)組的長度為key進(jìn)行排序
{"query":{"match_all":{}},"sort":{"_script":{"script":"doc['timedelta'].size()","type":"number","order":"desc"}}}
按照_id查詢數(shù)據(jù)
GET index_name/_doc/160657
or
GET index_name/_search{
? "query": {
? ? ? ? "term": {
? ? ? ? ? "_id": "1fd1ab67acd4ea042661b03a4d9c1cfb62095b79"
? ? ? ?}
? }
}
多個詞查詢數(shù)據(jù)
{
? "query": {
? ? ? ? "terms": {
? ? ? ? ? "post.keyword": [
? ? ? ? ? ? "區(qū)塊鏈","隱私計算"
? ? ? ? ? ]
? ? ? ? }
? }
}