forked from codingexplained/complete-guide-to-elasticsearch
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
180 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
# Configuring built-in analyzers | ||
|
||
## Configuring the `standard` analyzer | ||
|
||
``` | ||
PUT /analyzers_test | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"analyzer": { | ||
"english_stop": { | ||
"type": "standard", | ||
"stopwords": "_english_" | ||
} | ||
}, | ||
"filter": { | ||
"my_stemmer": { | ||
"type": "stemmer", | ||
"name": "english" | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Testing the custom analyzer | ||
|
||
``` | ||
POST /analyzers_test/_analyze | ||
{ | ||
"analyzer": "english_stop", | ||
"text": "I'm in the mood for drinking semi-dry red wine!" | ||
} | ||
``` | ||
|
||
``` | ||
POST /analyzers_test/_analyze | ||
{ | ||
"tokenizer": "standard", | ||
"filter": [ "my_stemmer" ], | ||
"text": "I'm in the mood for drinking semi-dry red wine!" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
# Creating custom analyzers | ||
|
||
## Adding a custom analyzer | ||
|
||
``` | ||
PUT /analyzers_test | ||
{ | ||
"settings": { | ||
"analysis": { | ||
"filter": { | ||
"my_stemmer": { | ||
"type": "stemmer", | ||
"name": "english" | ||
} | ||
}, | ||
"analyzer": { | ||
"english_stop": { | ||
"type": "standard", | ||
"stopwords": "_english_" | ||
}, | ||
"my_analyzer": { | ||
"type": "custom", | ||
"tokenizer": "standard", | ||
"char_filter": [ | ||
"html_strip" | ||
], | ||
"filter": [ | ||
"standard", | ||
"lowercase", | ||
"trim", | ||
"my_stemmer" | ||
] | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Testing the custom analyzer | ||
|
||
``` | ||
POST /analyzers_test/_analyze | ||
{ | ||
"analyzer": "my_analyzer", | ||
"text": "I'm in the mood for drinking <strong>semi-dry</strong> red wine!" | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
# Using analyzers in mappings | ||
|
||
## Using a custom analyzer in field mappings | ||
|
||
``` | ||
PUT /analyzers_test/default/_mapping | ||
{ | ||
"properties": { | ||
"description": { | ||
"type": "text", | ||
"analyzer": "my_analyzer" | ||
}, | ||
"teaser": { | ||
"type": "text", | ||
"analyzer": "standard" | ||
} | ||
} | ||
} | ||
``` | ||
|
||
## Adding a test document | ||
|
||
``` | ||
POST /analyzers_test/default/1 | ||
{ | ||
"description": "drinking", | ||
"teaser": "drinking" | ||
} | ||
``` | ||
|
||
## Testing the mapping | ||
|
||
``` | ||
GET /analyzers_test/default/_search | ||
{ | ||
"query": { | ||
"term": { | ||
"teaser": { | ||
"value": "drinking" | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
||
``` | ||
GET /analyzers_test/default/_search | ||
{ | ||
"query": { | ||
"term": { | ||
"description": { | ||
"value": "drinking" | ||
} | ||
} | ||
} | ||
} | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# Using the `_analyze` API | ||
|
||
## Tokenizing text with the `standard` tokenizer | ||
|
||
``` | ||
POST _analyze | ||
{ | ||
"tokenizer" : "standard", | ||
"text": "I'm in the mood for drinking semi-dry red wine!" | ||
} | ||
``` | ||
|
||
## Using the `lowercase` token filter | ||
|
||
``` | ||
POST _analyze | ||
{ | ||
"filter" : [ "lowercase" ], | ||
"text": "I'm in the mood for drinking semi-dry red wine!" | ||
} | ||
``` | ||
|
||
## Using the `standard` analyzer | ||
|
||
``` | ||
POST _analyze | ||
{ | ||
"analyzer": "standard", | ||
"text": "I'm in the mood for drinking semi-dry red wine!" | ||
} | ||
``` |