Java ElasticSearch无法找到字符串字段中存在的精确值
当我做一个空查询来列出一些结果时,我看到值就在那里。例:Java ElasticSearch无法找到字符串字段中存在的精确值,java,
elasticsearch,lucene,Java,
elasticsearch,Lucene,当我做一个空查询来列出一些结果时,我看到值就在那里。例: { "took": 6, "timed_out": false, "_shards": { "total": 5, "successful": 5, "failed": 0 }, "hits": { "total": 3024, "max_score": 1.0, "hits": [{
{
"took": 6,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 3024,
"max_score": 1.0,
"hits": [{
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5-j6uVuoyTMhX204",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1029.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5-mTuVuoyTMhX205",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1321.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5-xkuVuoyTMhX209",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail2567.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5zr8uVuoyTMhX20F",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail2122.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5z23uVuoyTMhX20L",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1823.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5-53uVuoyTMhX21A",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1616.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5_AXuVuoyTMhX21C",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail3002.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5_j3uVuoyTMhX21U",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail3039.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5_yQuVuoyTMhX21d",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1136.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5zbquVuoyTMhX20C",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail166.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5zfsuVuoyTMhX20E",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail2767.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt59jQuVuoyTMhX20p",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail2852.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5_PpuVuoyTMhX21J",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1392.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt58YguVuoyTMhX20N",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail603.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5_38uVuoyTMhX21h",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail416.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt5-JFuVuoyTMhX20y",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail896.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt6B1NuVuoyTMhX22i",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail846.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt6B3vuVuoyTMhX22k",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1214.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt6B90uVuoyTMhX22o",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail1536.png"
}
}, {
"_index": "geotiff_test",
"_type": "geometa",
"_id": "AVtt6COkuVuoyTMhX22y",
"_score": 1.0,
"_source": {
"thumbnail": "thumbnail246.png"
}
}]
}
}
但是,当我运行这样的查询时,它不会返回任何结果:
curl -X POST http://localhost:9200/geotiff_test/geometa/_search -d '{
"query": {
"term": {
"thumbnail": "thumbnail1536.png"
}
}
}'
结果是:
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
如果这是Solr,我只想运行这个简单的查询:thumbnail1536.png“
有人能告诉我这里出了什么问题吗?这取决于字段的映射/键入方式。请参考弹性搜索网站上的内容
请注意,您可以更改映射以更好地满足您的需要。这取决于字段的映射/键入方式。请参考弹性搜索网站上的内容
请注意,您可以更改映射以更好地满足您的需要。精确术语不匹配,因为您的文档字段
缩略图
已使用标准
分析器进行分析,并将其存储为缩略图1536
和png
在Elasticsearch中,对文本
(全文)和关键字
(确切术语)有不同的查询。你写的那个属于后一类
如果运行以下全文查询,您将获得所需的结果:
curl -X POST http://localhost:9200/geotiff_test/geometa/_search -d '{
"query": {
"match": {
"thumbnail": "thumbnail1536.png"
}
}
}'
但是,当您尝试使用术语搜索确切术语时,首选查询
curl -X POST http://localhost:9200/geotiff_test/geometa/_search -d '{
"query": {
"term": {
"thumbnail.keyword": "thumbnail1536.png"
}
}
}'
注意:这里的.keyword
是缩略图
字段的关键字
版本
虽然两个查询都产生相同的结果,但上面的查询比前一个查询效率更高 精确术语不匹配,因为您的文档字段缩略图
已使用标准
分析器进行分析,并将其存储为thumbnail1536
和png
在Elasticsearch中,对文本
(全文)和关键字
(确切术语)有不同的查询。你写的那个属于后一类
如果运行以下全文查询,您将获得所需的结果:
curl -X POST http://localhost:9200/geotiff_test/geometa/_search -d '{
"query": {
"match": {
"thumbnail": "thumbnail1536.png"
}
}
}'
但是,当您尝试使用术语搜索确切术语时,首选查询
curl -X POST http://localhost:9200/geotiff_test/geometa/_search -d '{
"query": {
"term": {
"thumbnail.keyword": "thumbnail1536.png"
}
}
}'
注意:这里的.keyword
是缩略图
字段的关键字
版本
虽然两个查询都产生相同的结果,但上面的查询比前一个查询效率更高 我真的是个新手。所以我不知道为什么这很重要,因为在Solr中,该查询将对字符串或文本字段起作用。所以我不知道为什么这很重要,因为在Solr中,该查询将针对字符串或文本字段。