Elasticsearch Introduction, stand-alone installation, Python write Elasticsearch API

Source: Internet
Author: User

Elasticsearch is an open source, distributed, restful search engine built on Lucene. Designed for cloud computing, to achieve real-time search, stable, reliable, fast, easy to install and use. Supports the use of JSON for data indexing over HTTP.

stand-alone Environment

Stand-alone version of the Elasticsearch operation is very simple, Linux directly under the Bin/elasticsearch run, Windows run Bin/elasticsearch.bat. If it is in the LAN running Elasticsearch cluster is also very simple, as long as the cluster.name set consistent, and the machine under the same network segment, the boot of the ES will automatically find each other, composed of cluster installation head plug-ins:

Elasticsearch-head is a elasticsearch cluster management tool.

1.elasticsearch/bin/plugin-install Aconex/elasticsearch-head

2. Running ES

3. Open http://localhost:9200/_plugin/head/


Install Elasticsearch-bigdesk:

Bigdesk is a elasticsearch cluster monitoring tool that allows you to view the various states of the ES cluster

1.bin/plugin-install Lukas-vlcek/bigdesk

2. Running ES

3. Open http://localhost:9200/_plugin/bigdesk/



I tried to write a piece of code in Python that put the data in Elasticsearch.


#-*-Coding:utf-8-*-

From Elasticsearch import Elasticsearch

From Elasticsearch Import Helpers

From datetime import datetime

Import Sys

Sys.path.append ("..")

Import Uuid,time

From Core.logger import Mlogger

#sys. Path.append ("..")

Class Elasticsearchadapter (Nosqlbase):

# "" "Elasticsearch Interface Class" "


def __init__ (self,pconf):

Super (Elasticsearchadapter, self). __init__ ()

self.es = Elasticsearch (hosts= "10.11.115.61")

def save (Self,data):

idx = ' Default_index '

Try

Typ = ' Default_type '

Self.es.index (Index=idx, Doc_type=typ, body={"Data":d ata, "Datastore_timestamp": Time.time ()})

Except Exception, E:

Mlogger.error (e)

if __name__ = = ' __main__ ':

Myes = Elasticsearchadapter ()

data = [{' meta ': {u ' profile ': U ' cesa.profile ', U ' proc_url ': False,

U ' uitem ': {u ' url ': U ' https://lists.centos.org/pipermail/centos-announce/2015-June/021188.html ',

U ' cur_depth ': 2, U ' session ': U ' 1448330880.0 ',

U ' conf ': {u ' max_depth ': U ' 5 ', U ' proxy ': U '}},

U ' handler ': U ' Web ',

U ' model ': 0,

U ' data_pipe ': U ' es1 ',

U ' proc_data ': true}, 

U ' extracted_data ': {u ' url ': U ' https://lists.centos.org/pipermail/centos-announce/2015-June/021188.html ', U ' url_ Hash ': U ' 455e66caa91b086001bbfa8233c2823f ', U ' id ': U ' ceba-2015:1129 ', U ' cesa_cesa ': U ' \ncentos errata and Bugfix Advisory 2015:1129 \n\nupstream details at:https://rhn.redhat.com/errata/rhba-2015-1129.html\n\nthe following Updated files have been uploaded and are currently \nsyncing to the mirrors: (sha256sum Filename) \n\ni386:\n6a054b6d1c2 E935099F6C132700800ECC0A7EB26FB2845F11B7DFB91D12837A1  mysql-5.1.73-5.el6_6.i686.rpm\ ndf9217eccc375a1c482b7ab2b0b1695ba1eb80c3feddef7069201e83e15d1354  mysql-bench-5.1.73-5.el6_6.i686.rpm\ n162ca8230d9765e02e2b1408ea4175c6cbd5ec995e563bbce1ca2d5df901ff9e  mysql-embedded-5.1.73-5.el6_6.x86_64. Rpm\na6fa3a975508308abb1a3ba7d9ef013ecaf8ea1921e89cc8d7075c2726e30bb8  mysql-embedded-devel-5.1.73-5.el6_ 6.i686.rpm\n640c0b911f3506e7e514dc3d188c055609e9880d7f613072cb1614ec4cf58b5f   Mysql-embedded-devel-5.1.73-5.el6_6.x86_64. rpm\ndf3c62f47d6e40ddc6d024b064d52935432a73920ddb04b51dae5f7a30dd2412  mysql-libs-5.1.73}

}]

Print Myes.save (data)


I am also the first contact with ES if there is any problem, please feel free to advise

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.