简体   繁体   English

Elasticsearch HTTP API或python API

[英]Elasticsearch HTTP API or python API

I am newbie in the real-time distributed search engine elasticsearch, but I would like to ask a technical question. 我是实时分布式搜索引擎elasticsearch的新手,但我想问一个技术问题。

I have written a python module-crawler that parses a web page and creates JSON objects with native information. 我已经编写了一个python模块爬网程序,该爬网程序解析网页并使用本地信息创建JSON对象。 The next step for my module-crawler is to store the native information, using the elasticsearch. 我的模块抓取工具的下一步是使用elasticsearch存储本机信息。

The real question is the following. 真正的问题如下。 Which technique is better for my occasion? 哪种技术更适合我的场合? The elasticsearch RESTful API or the python API for elastic search (elasticsearch-py) ? 用于弹性搜索的elasticsearch RESTful API或python API(elasticsearch-py)?

If you already have Python code, then the most natural way for you would be to use the elasticsearch-py client . 如果您已经有了Python代码,那么最自然的方法是使用elasticsearch-py client

After installing the elasticsearch-py library via pip install elatsicsearch , you can find a simple code example to get you going: 通过pip install elatsicsearch elasticsearch-py库后,您可以找到一个简单的代码示例以开始工作:

# import the elasticsearch library
from elasticsearch import Elasticsearch

# get your JSON data
json_page = {...}

# create a new client to connect to ES running on localhost:9200
es = Elasticsearch()

# index your JSON data
es.index(index="webpages", doc_type="webpage", id=1, body=json_page)

你也可以尝试elasticsearch_dsl它是一种高层次的wraper elasticsearch

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM