ElasticSearch是一个基于Lucene构建的开源,分布式,RESTful搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便.
1、 wget http://download.oracle.com/otn-pub/java/jdk/7u71-b14/jdk-7u71-linux-i586.rpm?AuthParam=1416296390_276056c6b0870494311edae301500e4f
2、 sudo rpm -ivh jdk-7u71-linux-i586.rpm
3、 which java
4、 vi ~/.bash_profile
export JAVA_HOME=/usr/java/jdk1.7.0_71
5、 source ~/.bash_profile && java –version
6、 wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.0.tar.gz
7、 tar zxf elasticsearch-1.4.0.tar.gz && cd elasticsearch-1.4.0/config
8、 vim elasticsearch.yml
node.name: "hiwechat"
index.number_of_shards: 10
index.number_of_replicas: 1
9、 cd ../bin
10、 ./elasticsearch –d
11、 telnet 127.0.0.1 9300
12、 ./plugin -install medcl/elasticsearch-analysis-ik/1.2.6
13、 cd ../config/
14、 wget http://github.com/downloads/medcl/elasticsearch-analysis-ik/ik.zip
15、 unzip ik.zip
16、 rm -rf ik.zip
other: https://github.com/medcl/elasticsearch-rtf
17、 yum install python-pip
18、 pip install argparse
19、 pip install elasticsearch
20、 curl -X GET localhost:9200
21、 python
>>> from datetime import datetime
>>> from elasticsearch import Elasticsearch
# by default we connect to localhost:9200
>>> es = Elasticsearch()
# create an index in elasticsearch, ignore status code 400 (index alreadyexists)
>>> es.indices.create(index='my-index', ignore=400)
{u'acknowledged': True}
# datetimes will be serialized
>>> es.index(index="my-index",doc_type="test-type", id=42, body={"any": "data","timestamp": datetime.now()})
{u'_id': u'42', u'_index': u'my-index', u'_type': u'test-type',u'_version': 1, u'ok': True}
# but not deserialized
>>> es.get(index="my-index",doc_type="test-type", id=42)['_source']
{u'any': u'data', u'timestamp': u'2013-05-12T19:45:31.804229'}