В целом вы правы, но это также зависит от значений параметров min_gram
и max_gram
.
Посмотрите ниже.
Пример 1.
min_gram = 2
и max_gram = 10
Отображение
PUT /so54090009
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 2,
"max_gram": 10,
"token_chars": [
"letter",
"digit",
"whitespace"
]
}
}
}
}
}
Анализ
POST /so54090009/_analyze
{
"analyzer": "my_analyzer",
"text": "2 red foxes"
}
Ответ
{
"tokens": [
{
"token": "2 ",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 0
},
{
"token": "2 r",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 1
},
{
"token": "2 re",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 2
},
{
"token": "2 red",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 3
},
{
"token": "2 red ",
"start_offset": 0,
"end_offset": 6,
"type": "word",
"position": 4
},
{
"token": "2 red f",
"start_offset": 0,
"end_offset": 7,
"type": "word",
"position": 5
},
{
"token": "2 red fo",
"start_offset": 0,
"end_offset": 8,
"type": "word",
"position": 6
},
{
"token": "2 red fox",
"start_offset": 0,
"end_offset": 9,
"type": "word",
"position": 7
},
{
"token": "2 red foxe",
"start_offset": 0,
"end_offset": 10,
"type": "word",
"position": 8
}
]
}
Пример 2.
min_gram = 1
и max_gram = 5
Отображение
PUT /so54090009
{
"settings": {
"analysis": {
"analyzer": {
"my_analyzer": {
"tokenizer": "my_tokenizer"
}
},
"tokenizer": {
"my_tokenizer": {
"type": "edge_ngram",
"min_gram": 1,
"max_gram": 5,
"token_chars": [
"letter",
"digit",
"whitespace"
]
}
}
}
}
}
Анализ
POST /so54090009/_analyze
{
"analyzer": "my_analyzer",
"text": "2 red foxes"
}
Ответ
{
"tokens": [
{
"token": "2",
"start_offset": 0,
"end_offset": 1,
"type": "word",
"position": 0
},
{
"token": "2 ",
"start_offset": 0,
"end_offset": 2,
"type": "word",
"position": 1
},
{
"token": "2 r",
"start_offset": 0,
"end_offset": 3,
"type": "word",
"position": 2
},
{
"token": "2 re",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 3
},
{
"token": "2 red",
"start_offset": 0,
"end_offset": 5,
"type": "word",
"position": 4
}
]
}