Skip to content

Commit 2eccd84

Browse files
committed
Added new Mapping & Analysis section
1 parent ae8952e commit 2eccd84

30 files changed

+1150
-393
lines changed

Analysis & Analyzers/configuring-built-in-analyzers.md

-44
This file was deleted.

Analysis & Analyzers/creating-custom-analyzers.md

-47
This file was deleted.

Analysis & Analyzers/using-analyzers-in-mappings.md

-57
This file was deleted.

Analysis & Analyzers/using-the-analyze-api.md

-31
This file was deleted.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Adding analyzers to existing indices
2+
3+
## Close `analyzer_test` index
4+
```
5+
POST /analyzer_test/_close
6+
```
7+
8+
## Add new analyzer
9+
```
10+
PUT /analyzer_test/_settings
11+
{
12+
"analysis": {
13+
"analyzer": {
14+
"my_second_analyzer": {
15+
"type": "custom",
16+
"tokenizer": "standard",
17+
"char_filter": ["html_strip"],
18+
"filter": [
19+
"lowercase",
20+
"stop",
21+
"asciifolding"
22+
]
23+
}
24+
}
25+
}
26+
}
27+
```
28+
29+
## Open `analyzer_test` index
30+
```
31+
POST /analyzer_test/_open
32+
```
33+
34+
## Retrieve index settings
35+
```
36+
GET /analyzer_test/_settings
37+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# Adding explicit mappings
2+
3+
## Add field mappings for `reviews` index
4+
```
5+
PUT /reviews
6+
{
7+
"mappings": {
8+
"properties": {
9+
"rating": { "type": "float" },
10+
"content": { "type": "text" },
11+
"product_id": { "type": "integer" },
12+
"author": {
13+
"properties": {
14+
"first_name": { "type": "text" },
15+
"last_name": { "type": "text" },
16+
"email": { "type": "keyword" }
17+
}
18+
}
19+
}
20+
}
21+
}
22+
```
23+
24+
## Index a test document
25+
```
26+
PUT /reviews/_doc/1
27+
{
28+
"rating": 5.0,
29+
"content": "Outstanding course! Bo really taught me a lot about Elasticsearch!",
30+
"product_id": 123,
31+
"author": {
32+
"first_name": "John",
33+
"last_name": "Doe",
34+
"email": "johndoe123@example.com"
35+
}
36+
}
37+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
# Adding mappings to existing indices
2+
3+
## Add new field mapping to existing index
4+
```
5+
PUT /reviews/_mapping
6+
{
7+
"properties": {
8+
"created_at": {
9+
"type": "date"
10+
}
11+
}
12+
}
13+
```
14+
15+
## Retrieve the mapping
16+
```
17+
GET /reviews/_mapping
18+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# Combining explicit and dynamic mapping
2+
3+
## Create index with one field mapping
4+
```
5+
PUT /people
6+
{
7+
"mappings": {
8+
"properties": {
9+
"first_name": {
10+
"type": "text"
11+
}
12+
}
13+
}
14+
}
15+
```
16+
17+
## Index a test document with an unmapped field
18+
```
19+
POST /people/_doc
20+
{
21+
"first_name": "Bo",
22+
"last_name": "Andersen"
23+
}
24+
```
25+
26+
## Retrieve mapping
27+
```
28+
GET /people/_mapping
29+
```
30+
31+
## Clean up
32+
```
33+
DELETE /people
34+
```
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
# Configuring dynamic mapping
2+
3+
## Disable dynamic mapping
4+
```
5+
PUT /people
6+
{
7+
"mappings": {
8+
"dynamic": false,
9+
"properties": {
10+
"first_name": {
11+
"type": "text"
12+
}
13+
}
14+
}
15+
}
16+
```
17+
18+
## Set dynamic mapping to `strict`
19+
```
20+
PUT /people
21+
{
22+
"mappings": {
23+
"dynamic": "strict",
24+
"properties": {
25+
"first_name": {
26+
"type": "text"
27+
}
28+
}
29+
}
30+
}
31+
```
32+
33+
## Index a test document
34+
```
35+
POST /people/_doc
36+
{
37+
"first_name": "Bo",
38+
"last_name": "Andersen"
39+
}
40+
```
41+
42+
## Retrieve mapping
43+
```
44+
GET /people/_mapping
45+
```
46+
47+
## Search `first_name` field
48+
```
49+
GET /people/_search
50+
{
51+
"query": {
52+
"match": {
53+
"first_name": "Bo"
54+
}
55+
}
56+
}
57+
```
58+
59+
## Search `last_name` field
60+
```
61+
GET /people/_search
62+
{
63+
"query": {
64+
"match": {
65+
"last_name": "Andersen"
66+
}
67+
}
68+
}
69+
```
70+
71+
## Clean up
72+
```
73+
DELETE /people
74+
```

0 commit comments

Comments
 (0)