0
0
Elasticsearchquery~10 mins

Field and document level security in Elasticsearch - Interactive Code Practice

Choose your learning style9 modes available
Practice - 5 Tasks
Answer the questions below
1fill in blank
easy

Complete the code to specify fields to include in the search response.

Elasticsearch
{
  "_source": {
    "includes": [[1]]
  }
}
Drag options to blanks, or click blank then click option'
A"user.name"
B"user.name", "user.email"
C"user"
D"name", "email"
Attempts:
3 left
💡 Hint
Common Mistakes
Putting multiple fields as a single string without quotes.
Using field names without quotes.
2fill in blank
medium

Complete the query to filter documents where the field 'status' equals 'active'.

Elasticsearch
{
  "query": {
    "term": {
      "status": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A{"term": "active"}
Bactive
C"active"
D{"value": "active"}
Attempts:
3 left
💡 Hint
Common Mistakes
Omitting quotes around the value.
Using an incorrect object structure.
3fill in blank
hard

Fix the error in the document level security filter to allow only documents with 'role' field equal to 'admin'.

Elasticsearch
{
  "query": {
    "bool": {
      "filter": {
        "term": {
          "role": [1]
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aadmin
B"admin"
C{"value": "admin"}
D["admin"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using unquoted strings causing syntax errors.
Passing arrays instead of a single value.
4fill in blank
hard

Fill both blanks to create a field level security rule that excludes the 'salary' field and includes the 'name' field.

Elasticsearch
{
  "_source": {
    "includes": [[1]],
    "excludes": [[2]]
  }
}
Drag options to blanks, or click blank then click option'
A"name"
B"salary"
C"email"
D"address"
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up includes and excludes.
Not using quotes around field names.
5fill in blank
hard

Fill all three blanks to create a document level security query that filters documents where 'department' is 'sales' and only includes 'employee.name' and excludes 'employee.salary'.

Elasticsearch
{
  "query": {
    "term": {
      "department": [1]
    }
  },
  "_source": {
    "includes": [[2]],
    "excludes": [[3]]
  }
}
Drag options to blanks, or click blank then click option'
A"sales"
B"employee.name"
C"employee.salary"
D"employee.department"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around string values.
Mixing up included and excluded fields.