匹配所有查询
编辑匹配所有查询编辑
最简单的查询,匹配所有文档,并为所有文档赋予 _score
为 1.0
。
$params = [ 'body' => [ 'query' => [ 'match_all' => [ ], ], ], ]; $response = $client->search($params);
resp = client.search( body={"query": {"match_all": {}}}, ) print(resp)
response = client.search( body: { query: { match_all: {} } } ) puts response
res, err := es.Search( es.Search.WithBody(strings.NewReader(`{ "query": { "match_all": {} } }`)), es.Search.WithPretty(), ) fmt.Println(res, err)
const response = await client.search({ body: { query: { match_all: {} } } }) console.log(response)
GET /_search { "query": { "match_all": {} } }
可以使用 boost
参数更改 _score
。
resp = client.search( body={"query": {"match_all": {"boost": 1.2}}}, ) print(resp)
response = client.search( body: { query: { match_all: { boost: 1.2 } } } ) puts response
res, err := es.Search( es.Search.WithBody(strings.NewReader(`{ "query": { "match_all": { "boost": 1.2 } } }`)), es.Search.WithPretty(), ) fmt.Println(res, err)
GET /_search { "query": { "match_all": { "boost" : 1.2 } } }
匹配无查询编辑
这是 match_all
查询的逆运算,它不匹配任何文档。
resp = client.search( body={"query": {"match_none": {}}}, ) print(resp)
response = client.search( body: { query: { match_none: {} } } ) puts response
res, err := es.Search( es.Search.WithBody(strings.NewReader(`{ "query": { "match_none": {} } }`)), es.Search.WithPretty(), ) fmt.Println(res, err)
GET /_search { "query": { "match_none": {} } }