Mapping 弹性搜索如何在couchdb的附件文件中查找单词?
嗨,请给我指示/ 我正在使用elasticsearch 0.17.6和couchdb 1.1.0 我在couchdb上创建了两个文档: 每个文档都有字符串字段:名称、消息。第一个由文本文件“test.txt”附加,第二个不是。CouchDB生成的JSon代码如下:Mapping 弹性搜索如何在couchdb的附件文件中查找单词?,mapping,couchdb,attachment,elasticsearch,Mapping,Couchdb,Attachment,elasticsearch,嗨,请给我指示/ 我正在使用elasticsearch 0.17.6和couchdb 1.1.0 我在couchdb上创建了两个文档: 每个文档都有字符串字段:名称、消息。第一个由文本文件“test.txt”附加,第二个不是。CouchDB生成的JSon代码如下: { "_id": "ID1", "_rev": "6-e1ab4c5c65b98e9a0d91e5c8fc1629bb", "name": "Document1", "message": "Evaluate Elast
{
"_id": "ID1",
"_rev": "6-e1ab4c5c65b98e9a0d91e5c8fc1629bb",
"name": "Document1",
"message": "Evaluate Elastic Search",
"_attachments": {
"test.txt": {
"content_type": "text/plain",
"revpos": 5,
"digest": "md5-REzvAVEZoSV69SLI/vaflQ==",
"length": 86,
"stub": true
}
}
}
{
"_id": "ID2",
"_rev": "2-72142ec18248cedb4dba67305d136aa8",
"name": "Document2",
"message": "test Elastic Search"
}
这两个文档位于名为my_test_Coach_db的数据库中
我已经使用Elasticsearch(ES)使用插件对这些文档进行了索引:river和mapper附件。对于每个给定的文本,我希望ES不仅可以在文档的字段中找到相应的文本,还可以在附件*.txt文件中找到。但这是不可能的。我尝试了很多方法:手动创建索引、映射(自动和手动)、配置河流等。但ES只能在文档字段中找到单词,而无法在*.txt附件文件中找到单词。我遵循现场指示,但也不起作用
谢谢你的回答
以下是我的命令:
curl -X PUT "localhost:9200/test_idx_1"
curl -X PUT "localhost:9200/test_idx_1/test_mapping_1/_mapping" -d '{
"test_mapping_1": {
"properties": {
"_attachments": {
"type": "attachment",
"index": "yes"
}
}
}
}'
curl -XPUT 'http://localhost:9200/_river/test_river_1/_meta' -d '{
"type": "couchdb",
"couchdb": {
"host": "localhost",
"port": 5984,
"db": "my_test_couch_db",
"filter": null
},
"index": {
"index": "test_idx_1",
"type": "test_mapping_1"
}
}'
然后,我尝试搜索
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search'
(两份文件很好地找到)
这是输出
{
"took": 3,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 0.081366636,
"hits": [
{
"_index": "my_test_couch_db",
"_type": "my_test_couch_db",
"_id": "ID2",
"_score": 0.081366636,
"_source": {
"message": "test Elastic Search",
"_rev": "2-72142ec18248cedb4dba67305d136aa8",
"_id": "ID2",
"name": "Document2"
}
}
]
}
}
如您所见,ES只能在消息字段中找到单词“test”,在*.text附件文件中找不到该单词
我尝试其他查询:
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search' -d '{
"query": {
"text": {
"_attachments": "test"
}
}
}'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search' -d '{
"query": {
"text": {
"_attachments.fields.file": "test"
}
}
}'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
输出为零。我尝试了其他映射,但也不起作用
这是为什么?如何解决这个问题?couchDb river尚未加载附件。 我已经更新了它,但仍在等待用户确认它工作正常 看 您可以在这里尝试:
如果它对您有效,我可以创建pull请求。couchDb river尚未加载附件。 我已经更新了它,但仍在等待用户确认它工作正常 看 您可以在这里尝试: 如果它对您工作正常,我可以创建pull请求
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search' -d '{
"query": {
"text": {
"_attachments": "test"
}
}
}'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search' -d '{
"query": {
"text": {
"_attachments.fields.file": "test"
}
}
}'
{
"took": 0,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 0,
"max_score": null,
"hits": []
}
}