0
0
Elasticsearchquery~10 mins

First search query 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 perform a basic match_all search query in Elasticsearch.

Elasticsearch
{
  "query": {
    [1]: {}
  }
}
Drag options to blanks, or click blank then click option'
Amatch_all
Bterm
Crange
Dmatch
Attempts:
3 left
💡 Hint
Common Mistakes
Using match without specifying a field causes errors.
Using term or range queries when you want all documents.
2fill in blank
medium

Complete the code to search for documents where the field 'title' matches 'Elasticsearch'.

Elasticsearch
{
  "query": {
    "match": {
      "[1]": "Elasticsearch"
    }
  }
}
Drag options to blanks, or click blank then click option'
Atitle
Bauthor
Cdate
Dcontent
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong field name like content or author.
Leaving the field name blank.
3fill in blank
hard

Fix the error in the query to correctly search for documents with 'status' equal to 'active'.

Elasticsearch
{
  "query": {
    "term": {
      "status": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
Aactive
B"active"
C{ "value": "active" }
D["active"]
Attempts:
3 left
💡 Hint
Common Mistakes
Not putting the value in quotes.
Using an array or object instead of a string.
4fill in blank
hard

Fill both blanks to create a range query that finds documents with 'age' greater than or equal to 30.

Elasticsearch
{
  "query": {
    "range": {
      "[1]": {
        "[2]": 30
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Aage
Bgte
Cgt
Dlte
Attempts:
3 left
💡 Hint
Common Mistakes
Using gt instead of gte when equality is needed.
Using wrong field names.
5fill in blank
hard

Fill all three blanks to create a bool query that must match 'python' in 'tags' and filter documents with 'published' date after '2020-01-01'.

Elasticsearch
{
  "query": {
    "bool": {
      "must": {
        "match": {
          "[1]": "python"
        }
      },
      "filter": {
        "range": {
          "[2]": {
            "[3]": "2020-01-01"
          }
        }
      }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atags
Bpublished
Cgt
Dgte
Attempts:
3 left
💡 Hint
Common Mistakes
Using gte instead of gt if strictly after date is needed.
Mixing up field names.