我使用的弹性搜索版本是es2.2 . 我输入与全文搜索官方教程相同的代码 . (https://www.elastic.co/guide/en/elasticsearch/guide/current/match-query.html)
似乎全文没有设置错误?谢谢!
我输入的代码如下:
curl -XDELETE 'localhost:9200/my_index '
curl -XPUT 'localhost:9200/my_index ' -d '
{
"settings": { "number_of_shards": 1 }
}'
curl -XPOST 'localhost:9200/my_index/my_type/_bulk' -d'
{ "index": { "_id": 1 }}
{ "title": "The quick brown fox" }
{ "index": { "_id": 2 }}
{ "title": "The quick brown fox jumps over the lazy dog" }
{ "index": { "_id": 3 }}
{ "title": "The quick brown fox jumps over the quick dog" }
{ "index": { "_id": 4 }}
{ "title": "Brown fox brown dog" }'
curl -XGET 'localhost:9200/my_index/my_type/_search' -d'
{
"query": {
"match": {
"title": "QUICK!"
}
}
}'
返回的结果是:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 1,
"successful": 1,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
当我输入存储在索引中的确切查询时,我只能获得一次命中 .
curl -XGET 'localhost:9200/my_index/my_type/_search' -d'
{
"query": {
"match": {
"title": "The quick brown fox"
}
}
}'
输出为:{“take”:1,“timed_out”:false,“_ shards”:{“total”:1,“success”:1,“failed”:0},“hits”:{“total”: 1,“max_score”:1.4054651,“命中”:[{“_ index”:“my_index”,“_ type”:“my_type”,“_ id”:“1”,“_ score”:1.4054651,“_ source”:{“ Headers “:”快速的棕色狐狸“}}]}}
我也测试了分析仪:
curl -XGET 'localhost:9200/_analyze' -d'
{
"analyzer": "standard",
"text": "Text to analyze"
}'
curl: (6) Couldn't resolve host 'GET' {"tokens":[{"token":"text","start_offset":0,"end_offset":4,"type": “","位置":0},{"令牌":"到"," start_offset ":5," end_offset ":7,"键入":" ","位置":1},{"令牌":"分析"," start_offset ":8," end_offset ":15,"键入":" ","位置” :2}]}
这个错误会影响结果吗?
1 回答
现在好了!问题是我没有为“ Headers ”索引设置“分析器” . 当我设置“分析器”时,全文搜索工作!我不应该相信默认的分析仪 .