Elasticsearch 无法正常运行 → 已经可以正常运行

用yum在CentOS 6.4上进行安装

    参考
$ sudo rpm --import http://packages.elasticsearch.org/GPG-KEY-elasticsearch
$ sudo vim /etc/yum.repos.d/elasticsearch.repo
[elasticsearch-1.3]
name=Elasticsearch repository for 1.3.x packages
baseurl=http://packages.elasticsearch.org/elasticsearch/1.3/centos
gpgcheck=1
gpgkey=http://packages.elasticsearch.org/GPG-KEY-elasticsearch
enabled=1
$ sudo yum install elasticsearch

启动

$ sudo service elasticsearch start

确定是否已启动

$ curl -XGET http://localhost:9200/
{
  "status" : 200,
  "name" : "King Bedlam",
  "version" : {
    "number" : "1.3.1",
    "build_hash" : "2de6dc5268c32fb49b205233c138d93aaf772015",
    "build_timestamp" : "2014-07-28T14:45:15Z",
    "build_snapshot" : false,
    "lucene_version" : "4.9"
  },
  "tagline" : "You Know, for Search"
}

尝试实践一下!执行Elasticsearch – Wantedly 工程师博客

安装插件

$ sudo /usr/share/elasticsearch/bin/plugin -install elasticsearch/marvel/latest
$ sudo /usr/share/elasticsearch/bin/plugin -install polyfractal/elasticsearch-inquisitor
$ sudo /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji/2.1.0

分析器的注册

$ curl -XPUT 'http://localhost:9200/wantedly-demo' -d \
'{
  "settings": {
    "analysis": {
      "filter": {
        "pos_filter": {
          "type": "kuromoji_part_of_speech",
          "stoptags": [
            "助詞-格助詞-一般",
            "助詞-終助詞"
          ]
        },
...(省略)...
}'

数据导入

$ sudo curl -XPOST 'http://localhost:9200/_bulk' -d \
'
 { "index": { "_index": "wantedly-demo", "_type": "company", "_id": "1" } }
 { "id": "1", "name": "wantedly",   "location": "東京都港区白金台 3-19-6 白金台ビル3F" }
'
{
  "took": 4,
  "errors": true,
  "items": [
    {
      "index": {
        "_index": "wantedly-demo",
        "_type": "company",
        "_id": "1",
        "status": 500,
        "error": "NoClassDefFoundError[org/apache/lucene/util/AttributeSource$AttributeFactory]"
      }
    }
  ]
}

不可以啦 (><)

顺便提一句,我的状态是黄色的,有什么问题吗?

$ curl -XGET 'http://localhost:9200/_cluster/health?pretty=true'
{
  "cluster_name" : "elasticsearch",
  "status" : "yellow",
  "timed_out" : false,
  "number_of_nodes" : 1,
  "number_of_data_nodes" : 1,
  "active_primary_shards" : 13,
  "active_shards" : 13,
  "relocating_shards" : 0,
  "initializing_shards" : 0,
  "unassigned_shards" : 13
}

追加信息:

我收到了 Elasticsearch 的核心开发人员 @johtani 的评论。

如果 kuromoji 的版本与 ES 版本不匹配的话,好像是不对的(如果是 ES 1.3 系列,则使用这个分支)
↓在 Wantedly 的网站上也写着这样!疏忽大意!

请使用与安装的 Elasticsearch 版本相匹配的适当的插件版本。

按照评论的建议,先删除然后重新添加。

$ sudo /usr/share/elasticsearch/bin/plugin --remove elasticsearch/elasticsearch-analysis-kuromoji
$ sudo /usr/share/elasticsearch/bin/plugin -install elasticsearch/elasticsearch-analysis-kuromoji/2.3.0

重启 Elasticsearch.

$ service elasticsearch restart

导入数据

$ sudo curl -XPOST 'http://localhost:9200/_bulk' -d \
'
 { "index": { "_index": "wantedly-demo", "_type": "company", "_id": "1" } }
 { "id": "1", "name": "wantedly",   "location": "東京都港区白金台 3-19-6 白金台ビル3F" }
'
{
  "took": 224,
  "errors": false,
  "items": [
    {
      "index": {
        "_index": "wantedly-demo",
        "_type": "company",
        "_id": "1",
        "_version": 1,
        "status": 201
      }
    }
  ]
}

顺利进行了吗?

试试用以下的查询语句。

GET /wantedly-demo/_search
{
  "query": {
    "simple_query_string": {
      "query": "白金台"
    }
  }
}
{
   "took": 14,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 0.011502187,
      "hits": [
         {
            "_index": "wantedly-demo",
            "_type": "company",
            "_id": "1",
            "_score": 0.011502187,
            "_source": {
               "id": "1",
               "name": "wantedly",
               "location": "東京都港区白金台 3-19-6 白金台ビル3F"
            }
         }
      ]
   }
}

好像做成了!!!

感谢 @johtani 先生!

bannerAds