0
0
Elasticsearchquery~10 mins

Full-text search engine concept 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 index named 'books'.

Elasticsearch
PUT /[1]
Drag options to blanks, or click blank then click option'
Abooks
Blibrary
Ctexts
Ddocuments
Attempts:
3 left
💡 Hint
Common Mistakes
Using a name unrelated to the data like 'library' or 'texts'.
Forgetting to use the PUT method.
2fill in blank
medium

Complete the code to add a document with id '1' to the 'books' index.

Elasticsearch
PUT /books/_doc/[1]
{
  "title": "Elasticsearch Basics",
  "author": "John Doe"
}
Drag options to blanks, or click blank then click option'
A1
Bdoc1
Cbook1
D001
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string like 'doc1' instead of the numeric id '1'.
Omitting the document id.
3fill in blank
hard

Fix the error in the search query to find documents with 'Elasticsearch' in the title.

Elasticsearch
GET /books/_search
{
  "query": {
    "match": {
      "title": "[1]"
    }
  }
}
Drag options to blanks, or click blank then click option'
AElastic search
Belastic_search
CElasticsearch
Delasticsearch basics
Attempts:
3 left
💡 Hint
Common Mistakes
Using 'Elastic search' with a space breaks the match.
Using underscores or extra words changes the search meaning.
4fill in blank
hard

Fill both blanks to create a query that searches for 'John' in the author field and sorts results by 'publish_date' descending.

Elasticsearch
GET /books/_search
{
  "query": {
    "match": {
      "[1]": "John"
    }
  },
  "sort": [
    {"[2]": {"order": "desc"}}
  ]
}
Drag options to blanks, or click blank then click option'
Aauthor
Btitle
Cpublish_date
Ddate
Attempts:
3 left
💡 Hint
Common Mistakes
Searching in the wrong field like 'title'.
Sorting by a non-existent or incorrect field.
5fill in blank
hard

Fill the blanks to create an aggregation that counts documents per 'genre' and filters genres with more than 5 documents.

Elasticsearch
GET /books/_search
{
  "size": 0,
  "aggs": {
    "genres_count": {
      "terms": {
        "field": "[1]",
        "min_doc_count": [2]
      }
    }
  },
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
Aauthor
Bgenre
C5
D10
Attempts:
3 left
💡 Hint
Common Mistakes
Using the wrong field like 'author' for aggregation.
Setting 'min_doc_count' too high or too low.