0
0
Elasticsearchquery~10 mins

Why indexes organize data in Elasticsearch - Test Your Understanding

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

Complete the code to create an index named 'products'.

Elasticsearch
PUT /[1]
Drag options to blanks, or click blank then click option'
Aproducts
Busers
Corders
Dcustomers
Attempts:
3 left
💡 Hint
Common Mistakes
Using a wrong index name that does not match the data type.
Forgetting to specify the index name after PUT.
2fill in blank
medium

Complete the code to add a document with ID '1' to the 'products' index.

Elasticsearch
PUT /products/_doc/[1]
{
  "name": "Laptop",
  "price": 1200
}
Drag options to blanks, or click blank then click option'
A10
B100
C1
D2
Attempts:
3 left
💡 Hint
Common Mistakes
Using an ID that does not match the document intended.
Omitting the document ID in the URL.
3fill in blank
hard

Fix the error in the query to search for products with price less than 1500.

Elasticsearch
{
  "query": {
    "range": {
      "price": { "[1]": 1500 }
    }
  }
}
Drag options to blanks, or click blank then click option'
Agt
Bgte
Clte
Dlt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'gt' or 'gte' which would find prices greater than or equal to 1500.
Using 'lte' which includes 1500, not strictly less.
4fill in blank
hard

Fill the blank to create an index with a mapping that sets 'price' as a double type.

Elasticsearch
PUT /products
{
  "mappings": {
    "properties": {
      "price": { "type": "[1]" }
    }
  }
}
Drag options to blanks, or click blank then click option'
Atext
Bdouble
Ckeyword
Dinteger
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'integer' which does not support decimals.
Using 'text' or 'keyword' which are for strings.
5fill in blank
hard

Fill all three blanks to write a query that finds products with name 'Laptop' and price greater than 1000.

Elasticsearch
{
  "query": {
    "bool": {
      "must": [
        { "match": { "name": "[1]" } },
        { "range": { "price": { "[2]": [3] } } }
      ]
    }
  }
}
Drag options to blanks, or click blank then click option'
ALaptop
Bgt
C1000
Dlt
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'lt' instead of 'gt' for price comparison.
Putting the wrong value for the name or price.