1

当我尝试使用 ES 网站进行演示时: https ://www.elastic.co/guide/en/elasticsearch/reference/current/_testing_analyzers.html - 自定义分析器的最新示例。这个例子不起作用。即使在示例中,我也没有更改任何内容。我认为它是 Elasticsearch 错误。有谁能够帮我?下面我展示了在 ubuntu 终端中显示 Elastichsearch 的命令和错误。当我尝试在 elasticsearch-php 中创建此示例时,也会发生相同的错误。

首先,我创建分析器,如示例所示:

curl -XPUT 'localhost:9200/my_index?pretty' -d'
> {
>   "settings": {
>     "analysis": {
>       "analyzer": {
>         "std_folded": { 
>           "type": "custom",
>           "tokenizer": "standard",
>           "filter": [
>             "lowercase",
>             "asciifolding"
>           ]
>         }
>       }
>     }
>   },
>   "mappings": {
>     "my_type": {
>       "properties": {
>         "my_text": {
>           "type": "text",
>           "analyzer": "std_folded" 
>         }
>       }
>     }
>   }
> }'
{
  "acknowledged" : true,
  "shards_acknowledged" : true
}

很好,分析器已创建。但测试示例不起作用:

curl -XGET 'localhost:9200/my_index/_analyze ?pretty' -d'
> {
>   "analyzer": "std_folded", 
>   "text":     "Is this déjà vu?"
> }'

ES回答我:

{
"error":
    {"root_cause":
    [{
        "type":"index_not_found_exception",
        "reason":"no such index",
        "resource.type":"index_or_alias",
        "resource.id":"bad-request",
        "index_uuid":"_na_",
        "index":"bad-request"
    }],
    "type":"index_not_found_exception",
    "reason":"no such index",
    "resource.type":"index_or_alias",
    "resource.id":"bad-request",
    "index_uuid":"_na_",
    "index":"bad-request"},
"status":404
}

我究竟做错了什么?我删除了所有索引并再次创建,我尝试重新启动 elasticsearch - 但无济于事。PS对不起我的英语不好。

4

1 回答 1

2

您的 GET 请求不正确。'_analyze' 和 '?pretty' 之间不应该有空格,所以你的 curl 应该是

curl -XGET 'localhost:9200/my_index/_analyze?pretty' -d'

其次是查询。

于 2017-01-01T20:25:59.077 回答