Complete the code to add a must clause that matches documents where the field status is active.
{
"query": {
"bool": {
"must": [
{ "term": { "status": "[1]" } }
]
}
}
}The must clause requires documents to have status equal to active.
Complete the code to add a should clause that boosts documents with category equal to electronics.
{
"query": {
"bool": {
"should": [
{ "term": { "category": "[1]" } }
]
}
}
}The should clause boosts documents with category equal to electronics, making them more relevant.
Fix the error in the must_not clause to exclude documents with status equal to archived.
{
"query": {
"bool": {
"must_not": [
{ "term": { "status": "[1]" } }
]
}
}
}The must_not clause excludes documents where status is archived.
Fill both blanks to create a filter clause that filters documents with price greater than 100 and less than 500.
{
"query": {
"bool": {
"filter": [
{ "range": { "price": { "gt": [1], "lt": [2] } } }
]
}
}
}The filter clause restricts documents to those with price greater than 100 and less than 500.
Fill all three blanks to build a bool query with must matching brand 'nike', should matching color 'red', and must_not matching size 'small'.
{
"query": {
"bool": {
"must": [
{ "term": { "brand": "[1]" } }
],
"should": [
{ "term": { "color": "[2]" } }
],
"must_not": [
{ "term": { "size": "[3]" } }
]
}
}
}This bool query requires documents with brand 'nike', boosts those with color 'red', and excludes those with size 'small'.