0
0
Elasticsearchquery~10 mins

Inverted index data structure 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 create an inverted index mapping terms to documents.

Elasticsearch
PUT /my_index/_doc/1 {
  "content": "apple banana cherry"
}

GET /my_index/_search {
  "query": {
    "match": {
      "content": "[1]"
    }
  }
}
Drag options to blanks, or click blank then click option'
Aapple
Bfruit
Corange
Dvegetable
Attempts:
3 left
💡 Hint
Common Mistakes
Searching for a word not in the document returns no results.
Using unrelated terms like 'fruit' or 'vegetable' won't match.
2fill in blank
medium

Complete the query to find documents containing the term 'banana'.

Elasticsearch
GET /my_index/_search {
  "query": {
    "match": {
      "content": "[1]"
    }
  }
}
Drag options to blanks, or click blank then click option'
Acherry
Bbanana
Capple
Dgrape
Attempts:
3 left
💡 Hint
Common Mistakes
Choosing terms not present in the documents.
Misspelling the term.
3fill in blank
hard

Fix the error in the query to correctly search for 'cherry'.

Elasticsearch
GET /my_index/_search {
  "query": {
    "match": {
      "content": [1]
    }
  }
}
Drag options to blanks, or click blank then click option'
A'cherry'
Bcherry
C"cherry"
D{cherry}
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting the search term causes syntax errors.
Using single quotes instead of double quotes.
4fill in blank
hard

Fill both blanks to create a query that searches for documents containing 'apple' or 'cherry'.

Elasticsearch
GET /my_index/_search {
  "query": {
    "bool": {
      "should": [
        { "match": { "content": [1] } },
        { "match": { "content": [2] } }
      ]
    }
  }
}
Drag options to blanks, or click blank then click option'
A"apple"
B"banana"
C"cherry"
D"date"
Attempts:
3 left
💡 Hint
Common Mistakes
Using terms not present in the documents.
Not quoting the terms properly.
5fill in blank
hard

Fill all three blanks to create a filtered query that searches for 'banana' and filters documents with 'status' equal to 'active'.

Elasticsearch
GET /my_index/_search {
  "query": {
    "bool": {
      "must": { "match": { "content": [1] } },
      "filter": { "term": { "status": [2] } }
    }
  },
  "_source": [3]
}
Drag options to blanks, or click blank then click option'
A"banana"
B"active"
C["content", "status"]
D["content"]
Attempts:
3 left
💡 Hint
Common Mistakes
Not quoting strings properly.
Using wrong field names or values.
Returning all fields instead of limiting with _source.