0
0
Elasticsearchquery~10 mins

Source filtering 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 include only the title field in the search results.

Elasticsearch
{
  "_source": [1],
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
A["title"]
B["content"]
C["date"]
D["author"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using a field name not present in the documents.
Not using an array for the fields.
2fill in blank
medium

Complete the code to exclude the comments field from the search results.

Elasticsearch
{
  "_source": {
    "excludes": [1]
  },
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
A["title"]
B["date"]
C["author"]
D["comments"]
Attempts:
3 left
💡 Hint
Common Mistakes
Using includes instead of excludes.
Not using an array for the field name.
3fill in blank
hard

Fix the error in the code to correctly include only the author and date fields.

Elasticsearch
{
  "_source": [1],
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
A["author", "date"]
B"author, date"
C{"author", "date"}
D"[author, date]"
Attempts:
3 left
💡 Hint
Common Mistakes
Using a string with comma-separated fields instead of an array.
Using curly braces which is invalid JSON here.
4fill in blank
hard

Fill both blanks to include only the title and summary fields, and exclude the comments field.

Elasticsearch
{
  "_source": {
    "includes": [1],
    "excludes": [2]
  },
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
A["title", "summary"]
B["author"]
C["comments"]
D["date"]
Attempts:
3 left
💡 Hint
Common Mistakes
Mixing up includes and excludes.
Not using arrays for the fields.
5fill in blank
hard

Fill all three blanks to include the title field in uppercase, include the author field, and exclude the comments field.

Elasticsearch
{
  "_source": {
    "includes": [[1], [3]],
    "excludes": [[2]]
  },
  "script_fields": {
    "title_upper": {
      "script": {
        "source": "doc['title'].value.toUpperCase()"
      }
    }
  },
  "query": {
    "match_all": {}
  }
}
Drag options to blanks, or click blank then click option'
A"title"
B"author"
C"comments"
D"summary"
Attempts:
3 left
💡 Hint
Common Mistakes
Forgetting quotes around field names.
Putting the wrong fields in includes or excludes.