匹配所有查询
编辑匹配所有查询
编辑最简单的查询,它匹配所有文档,并为它们都赋予一个 _score
为 1.0
。
$params = [ 'body' => [ 'query' => [ 'match_all' => [ ], ], ], ]; $response = $client->search($params);
resp = client.search( 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({ query: { match_all: {}, }, }); console.log(response);
GET /_search { "query": { "match_all": {} } }
可以使用 boost
参数更改 _score
。
resp = client.search( 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)
const response = await client.search({ query: { match_all: { boost: 1.2, }, }, }); console.log(response);
GET /_search { "query": { "match_all": { "boost" : 1.2 } } }
匹配无查询
编辑这是 match_all
查询的反向查询,它不匹配任何文档。
resp = client.search( 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)
const response = await client.search({ query: { match_none: {}, }, }); console.log(response);
GET /_search { "query": { "match_none": {} } }