Bird
0
0

You want to create an index with 2 shards and 0 replicas, but also want to add a custom analyzer named my_analyzer. Which JSON snippet correctly includes the analyzer in the index creation?

hard🚀 Application Q9 of 15
Elasticsearch - Index Management
You want to create an index with 2 shards and 0 replicas, but also want to add a custom analyzer named my_analyzer. Which JSON snippet correctly includes the analyzer in the index creation?
A{ "settings": { "number_of_shards": 2, "number_of_replicas": 0, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } }
B{ "settings": { "shards": 2, "replicas": 0, "analyzer": { "my_analyzer": { "type": "standard" } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } }
C{ "settings": { "number_of_shards": 2, "number_of_replicas": 0 }, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } }
D{ "settings": { "number_of_shards": 2, "number_of_replicas": 0 }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } }, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }
Step-by-Step Solution
Solution:
  1. Step 1: Locate where analysis settings belong

    Custom analyzers must be inside "settings" under "analysis".
  2. Step 2: Verify shard and replica keys

    { "settings": { "number_of_shards": 2, "number_of_replicas": 0, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } } correctly uses "number_of_shards" and "number_of_replicas" keys.
  3. Step 3: Confirm mappings use the analyzer

    { "settings": { "number_of_shards": 2, "number_of_replicas": 0, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } } assigns "my_analyzer" to the "content" field properly.
  4. Final Answer:

    { "settings": { "number_of_shards": 2, "number_of_replicas": 0, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } } -> Option A
  5. Quick Check:

    Analysis inside settings = { "settings": { "number_of_shards": 2, "number_of_replicas": 0, "analysis": { "analyzer": { "my_analyzer": { "type": "standard" } } } }, "mappings": { "properties": { "content": { "type": "text", "analyzer": "my_analyzer" } } } } [OK]
Quick Trick: Put analyzers inside "settings.analysis" [OK]
Common Mistakes:
MISTAKES
  • Placing analysis outside settings
  • Using wrong keys for shards
  • Not assigning analyzer in mappings

Want More Practice?

15+ quiz questions · All difficulty levels · Free

Free Signup - Practice All Questions
More Elasticsearch Quizzes