Если вы ничего не определяете, будет использоваться стандартный анализатор .
Стандартный анализатор создаст этот токен:
{
"token" : "org.apache.crimson.tree.xmldocument",
"start_offset" : 140,
"end_offset" : 175,
"type" : "<ALPHANUM>",
"position" : 22
}
Итак, ваш поискничего не находит.Если вы используете Pattern Analyzer , будет создан токен apache
.Шаблон по умолчанию \W+
(каждое слово) работает для вас.
Вы можете проверить это с помощью
curl -XGET "http://localhost:9200/_analyze" -H 'Content-Type: application/json' -d'
{
"text": "Sun Java Plug-In 1.4 through 1.4.2_02 allows remote attackers to repeatedly access the floppy drive via the createXmlDocument method in the org.apache.crimson.tree.XmlDocument class, which violates the Java security model.",
"analyzer": "pattern"
}'
Определите явное сопоставление для вашего индекса, например:
PUT customer
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 0
},
"mappings": {
"_doc": {
"properties": {
"description": {
"type": "text",
"analyzer": "pattern"
}
}
}
}
}
Если вы снова запустите запрос, вы получите, например:
"hits" : {
"total" : 1,
"max_score" : 0.2876821,
"hits" : [
{
"_index" : "customer",
"_type" : "_doc",
"_id" : "1",
"_score" : 0.2876821,
"_source" : {
"description" : "Sun Java Plug-In 1.4 through 1.4.2_02 allows remote attackers to repeatedly access the floppy drive via the createXmlDocument method in the org.apache.crimson.tree.XmlDocument class, which violates the Java security model."
}
}
]
}