Mappings Flashcards

1
Q

Create index with Mappings

A

PUT /my_index
{
“mappings”: {
“properties”: {
“title”: {
“type”: “text”,
“analyzer”: “standard”
},
“status”: {
“type”: “keyword”
},
“views”: {
“type”: “integer”
},
“published_date”: {
“type”: “date”,
“format”: “yyyy-MM-dd”
},
“is_active”: {
“type”: “boolean”
},
“author”: {
“properties”: {
“name”: {
“type”: “text”
},
“age”: {
“type”: “integer”
}
}
}
}
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How the mappings is analyzed

A

title is analyzed for full-text search.
status is a keyword, which is used for exact matching.
views is an integer.
published_date is a date in yyyy-MM-dd format.
is_active is a boolean.
author is an object, allowing you to store name as text and age as an integer.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Preparing the data

A

Ensure your data format aligns with the mappings defined in the index.

{
“title”: “Introduction to Elasticsearch”,
“status”: “published”,
“views”: 150,
“published_date”: “2024-01-01”,
“is_active”: true,
“author”: {
“name”: “Jane Doe”,
“age”: 34
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Ingest Data using Single Insert

A

POST /my_index/_doc/1
{
“title”: “Introduction to Elasticsearch”,
“status”: “published”,
“views”: 150,
“published_date”: “2024-01-01”,
“is_active”: true,
“author”: {
“name”: “Jane Doe”,
“age”: 34
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Insert data using bulk insert

A

POST /my_index/_bulk
{ “index”: { “_id”: “1” } }
{ “title”: “Introduction to Elasticsearch”, “status”: “published”, “views”: 150, “published_date”: “2024-01-01”, “is_active”: true, “author”: { “name”: “Jane Doe”, “age”: 34 } }
{ “index”: { “_id”: “2” } }
{ “title”: “Advanced Elasticsearch Techniques”, “status”: “draft”, “views”: 75, “published_date”: “2024-01-02”, “is_active”: false, “author”: { “name”: “John Smith”, “age”: 40 } }

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Update Mappings

A

PUT /my_index/_mapping
{
“properties”: {
“new_field”: {
“type”: “text”
}
}
}

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Common Mappings

A

Field Types - string,byte,short integer,long,float,double,boolean,date

Field Index - Field to be analyzed/not-analyzed for full text search?

Field Analyzer - Define your tokenizer and token filter
standard/whitespace/simple/english

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Analyzers

A

Character Filters
Remove HTML encoding, convert & to and

Tokenizer
Split strings on whitespace/punctuation/non-letters

Token Filter
Lowercasing, stemming, synonyms, stopwords

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly