你好,請給我indication./ 我使用1.1.0彈性搜索如何在couchdb的附件中找到單詞?
我對CouchDB的創建兩個文件elasticsearch 0.17.6和CouchDB的: 每個文檔有字符串字段:姓名,留言。第一個附加文本文件「test.txt」,第二個不是。通過CouchDB的產生JSON的代碼是這樣的:
{
"_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_couch_db
我使用Elasticsearch(ES)索引使用插件的這些文件:河流和映射器,附件。對於每個給定的文本,我希望ES可以在文檔的字段中找到相應的文本,而且還可以在附件* .txt文件中找到。但這是不可能的。我嘗試了很多方法:手動創建索引,映射(自動和手動),配置河流等,但ES只能在文檔的字段中找到單詞,無法找到* .txt附件中的單詞。我按照網站http://www.elasticsearch.org的指示,但它也沒有工作。
感謝您的回答。
這裏是我的命令:
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'
(兩個文件都覺得非常好)
curl -XPOST 'http://localhost:9200/my_test_couch_db/my_test_couch_db/_search' -d '{
"query": {
"text": {
"_all": "test"
}
}
}'
這裏是輸出
{
"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": []
}
}
輸出是什麼。我嘗試其他映射,但它也不起作用。
爲什麼會這樣以及如何解決這個問題?