Skip to content

Commit

Permalink
Added queries for analysis section
Browse files Browse the repository at this point in the history
  • Loading branch information
ba0708 committed Jul 22, 2017
1 parent 32a6e3a commit fcc22b9
Show file tree
Hide file tree
Showing 4 changed files with 180 additions and 0 deletions.
44 changes: 44 additions & 0 deletions Analysis & Analyzers/configuring-built-in-analyzers.md
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!"
}
```
48 changes: 48 additions & 0 deletions Analysis & Analyzers/creating-custom-analyzers.md
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!"
}
```
57 changes: 57 additions & 0 deletions Analysis & Analyzers/using-analyzers-in-mappings.md
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"
}
}
}
}
```
31 changes: 31 additions & 0 deletions Analysis & Analyzers/using-the-analyze-api.md
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!"
}
```

0 comments on commit fcc22b9

Please sign in to comment.