PDFファイルをMongo DbのgridFSに保存してから、エラスティック検索を使用してそのPDFを検索しようとしていました。私は以下を実行しました:
1) Mongo DB 側:
mongod --port 27017 --replSet rs0 --dbpath "D:\Mongo-DB\mongodb-win32-i386-2.0.7\data17"
mongod --port 27018 --replSet rs0 --dbpath "D:\Mongo-DB\mongodb-win32-i386-2.0.7\data18"
mongod --port 27019 --replSet rs0 --dbpath "D:\Mongo-DB\mongodb-win32-i386-2.0.7\data19"
mongo localhost:27017
rs.initiate()
rs.add("hostname:27018")
rs.add("hostname:27019")
mongofiles -hlocalhost:27017 --db testmongo --collection files --type application/pdf put D:\Sherlock-Holmes.pdf
2) Elastic Search側 (インストールプラグイン: bigdesk/head/mapper-attachments/river-mongodb)
-> [任意のリクエスト] タブからのリクエストに続いて、Elastic Search Head を使用する
URL : http://localhost:9200/_river/mongodb/
_meta/PUT
{
"type": "mongodb",
"mongodb": {
"db": "testmongo",
"collection": "fs.files",
"gridfs": true,
"contentType": "",
"content": "base64 /path/filename | perl -pe 's/\n/\\n/g'"
},
"index": {
"name": "testmongo",
"type": "files",
"content_type": "application/pdf"
}
}
今、私は次のURLにアクセスしようとしています:
http://localhost:9200/testmongo/files/508e82e21e43def09b5e1602?pretty=true
次の応答がありました(これは予想どおりだと思います):
{
"_index" : "testmongo",
"_type" : "files",
"_id" : "508e82e21e43def09b5e1602",
"_version" : 1,
"exists" : true, "_source" : {"_id":"508e82e21e43def09b5e1602","filename":"D:\\Sherlock-Holmes.pdf","chunkSize":262144,"uploadDate":"2012-10-29T13:21:38.969Z","md5":"025fa2046f9254d2aecb9e52ae851065","length":98272,"contentType":"application/pdf"}
}
しかし、次のURLを使用してこのpdfを検索しようとしたとき:
http://localhost:9200/testmongo/files/_search?q=Albers&pretty=true
次の結果が得られます:
{
"took" : 0,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}
ここでは、このpdfに存在する「Albers」という単語以外にヒットがないことを示しています。助けてください。前もって感謝します。