Elasticsearch と ManifoldCF

CentOS 7.0 上のファイルシステムに PDF や Excel, Word を置いて全文検索するまでの記録。

検索対象の文書ファイルを設置

ネットワーク穴あけ

systemctl stop firewalld.service

Elasticsearch を起動

rm -rf elasticsearch-1.2.2
tar xf elasticsearch-1.2.2.tar.gz
cd elasticsearch-1.2.2
export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
bin/plugin -i elasticsearch/elasticsearch-mapper-attachments/2.0.0 # 謎のプラグインを導入
./bin/elasticsearch

謎のプラグインの設定?

curl -X PUT localhost:9200/aiueo -d '{
    "settings" : { 
        "index" : {
            "number_of_shards" : 1,
            "number_of_replicas" : 0
        }
    }
}'
curl -X PUT localhost:9200/aiueo/file/_mapping -d '{
    "file" : {
        "properties" : {
            "file" : {
                "type" : "attachment"
            }
        }
    }
}'

ManifoldCF 起動

rm -rf apache-manifoldcf-1.6.1
tar xf apache-manifoldcf-1.6.1-bin.tar.gz
cd apache-manifoldcf-1.6.1/example/
export _JAVA_OPTIONS="-Djava.net.preferIPv4Stack=true"
java -jar start.jar

クローラーを動かす

出力先を定義

入力元を定義

ジョブ登録(入力と出力を関連付け)してジョブを起動

クエリーを投げる

[user2@cent7a ~]$ curl 'localhost:9200/aiueo/_search?q=gcc&pretty'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 1,
    "successful" : 1,
    "failed" : 0
  },
  "hits" : {
    "total" : 1,
    "max_score" : 1.2797858,
    "hits" : [ {
      "_index" : "aiueo",
      "_type" : "file",
      "_id" : "file:/home/user2/doc/gcc_-c_-fpic_bye_c.txt",
      "_score" : 1.2797858,
      "_source":{"uri" : "\/home\/user2\/doc\/gcc_-c_-fpic_bye_c.txt", これより右は省略
    } ]
  }
}

参考


2014/7/15 初版