すべてのクエリに一致
最も単純なクエリで、すべてのドキュメントに一致し、すべてに _score
の 1.0
を与えます。
Php
$params = [
'body' => [
'query' => [
'match_all' => [
],
],
],
];
$response = $client->search($params);
Python
resp = client.search(
query={
"match_all": {}
},
)
print(resp)
Ruby
response = client.search(
body: {
query: {
match_all: {}
}
}
)
puts response
Go
res, err := es.Search(
es.Search.WithBody(strings.NewReader(`{
"query": {
"match_all": {}
}
}`)),
es.Search.WithPretty(),
)
fmt.Println(res, err)
Js
const response = await client.search({
query: {
match_all: {},
},
});
console.log(response);
Console
GET /_search
{
"query": {
"match_all": {}
}
}
_score
は boost
パラメータで変更できます:
Python
resp = client.search(
query={
"match_all": {
"boost": 1.2
}
},
)
print(resp)
Ruby
response = client.search(
body: {
query: {
match_all: {
boost: 1.2
}
}
}
)
puts response
Go
res, err := es.Search(
es.Search.WithBody(strings.NewReader(`{
"query": {
"match_all": {
"boost": 1.2
}
}
}`)),
es.Search.WithPretty(),
)
fmt.Println(res, err)
Js
const response = await client.search({
query: {
match_all: {
boost: 1.2,
},
},
});
console.log(response);
Console
GET /_search
{
"query": {
"match_all": { "boost" : 1.2 }
}
}
一致しないクエリ
これは match_all
クエリの逆で、ドキュメントに一致しません。
Python
resp = client.search(
query={
"match_none": {}
},
)
print(resp)
Ruby
response = client.search(
body: {
query: {
match_none: {}
}
}
)
puts response
Go
res, err := es.Search(
es.Search.WithBody(strings.NewReader(`{
"query": {
"match_none": {}
}
}`)),
es.Search.WithPretty(),
)
fmt.Println(res, err)
Js
const response = await client.search({
query: {
match_none: {},
},
});
console.log(response);
Console
GET /_search
{
"query": {
"match_none": {}
}
}