Elasticsearch 匹配前缀,未找到匹配项

lfe*_*445 3 elasticsearch

遵循有关一些基本查询的弹性搜索教程:

#Create the index with no mapping
curl -XPUT 127.0.0.1:9200/startswith/

#add some data
curl -XPOST 127.0.0.1:9200/startswith/test/ -d '{"title":"river dog"}'
curl -XPOST 127.0.0.1:9200/startswith/test/ -d '{"title":"data"}'
curl -XPOST 127.0.0.1:9200/startswith/test/ -d '{"title":"drive"}'
curl -XPOST 127.0.0.1:9200/startswith/test/ -d '{"title":"dzone"}'

#try to perform a "starts-with" style query...
curl -XGET 127.0.0.1:9200/startswith/test/_search?pretty -d '{
        "query": {
        "match_phrase_prefix": {
           "title": {
             "query": "d",
             "max_expansions": 5
           }
         }
       }
     }' | grep title
Run Code Online (Sandbox Code Playgroud)

但我收到了消息no matches found: 127.0.0.1:9200/startswith/test/_search?pretty。如果我访问http://127.0.0.1:9200/startswith/test/_search或卷曲它,结果就在那里。我错过了什么?

Joa*_*son 5

这是壳的问题。

zsh用途?为外卡匹配,所以你必须把它引用到使用一个字符串。

例如;

> echo ?
zsh: no matches found: ?

> echo 127.0.0.1:9200/startswith/test/_search?pretty
zsh: no matches found: 127.0.0.1:9200/startswith/test/_search?pretty
Run Code Online (Sandbox Code Playgroud)

要修复它zsh,请引用字符串;

> echo "127.0.0.1:9200/startswith/test/_search?pretty"
127.0.0.1:9200/startswith/test/_search?pretty
Run Code Online (Sandbox Code Playgroud)

...或用反斜杠转义问号;

> echo 127.0.0.1:9200/startswith/test/_search\?pretty
127.0.0.1:9200/startswith/test/_search?pretty
Run Code Online (Sandbox Code Playgroud)