ElasticSearch是一个基于Lucene构建的开源,分布式,RESTful搜索引擎。设计用于云计算中,能够达到实时搜索,稳定,可靠,快速,安装使用方便

1、  下载jdk-7u71-linux-x64.gz

2、  Tar zxvf jdk-7u71-linux-x64.gz

3、  mv jdk1.7.0_71/ /home/work/local/java/

4、  vim /etc/profile

export JAVA_HOME=/home/work/local/java

exportJRE_HOME=/home/work/local/java/jre

exportCLASSPATH=.:$JAVA_HOME/lib:$JRE_HOME/lib:$CLASSPATH

export PATH=$JAVA_HOME/bin:$JRE_HOME/bin:$PATH

5、  java –version

6、  tar zxvf elasticsearch-1.3.4.tar.gz

7、  cd elasticsearch-1.3.4/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 -installmedcl/elasticsearch-analysis-ik/1.0.0

13、             cd ../config/

14、             wget http://github.com/downloads/medcl/elasticsearch-analysis-ik/ik.zip

15、             unzip ik.zip

16、             rm -rf ik.zip

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'}

 

参考资料:

         https://github.com/elasticsearch/elasticsearch-py