Запрос на соответствие всем документам
Самый простой запрос, который соответствует всем документам, присваивая им всем _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": {}
}
} Значение _score можно изменить параметром boost:
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": {}
}
}
© 2023-2025 Elasticsearch
As of September 2024, Elasticsearch is available under a choice of three licenses: the Server Side Public License (SSPL), the Elastic License, or the AGPLv3 (OSI approved).
Elasticsearch and the Elasticsearch logo are trademarks of Elasticsearch B.V., registered in the U.S. and in other countries.
https://www.elastic.co/guide/en/elasticsearch/reference/8.17/query-dsl-match-all-query.html