#书上例子,但是老版本es.修改后现在用es7.9最新环境运行 from elasticsearch import Elasticsearch import time index_settings = { "number_of_shards": 1, "number_of_replicas": 1, "index": { "analysis": { "analyzer": { "keyword_analyzed": { "type": "custom", "filter": [ "lowercase", "asciifolding" ], "tokenizer": "keyword" } } } } } doc_mapping = { "properties": { "skills": { "type": "text" } } } es = Elasticsearch('ip:9200') index_name = 'books' doc_type = "search" body = {} body['settings'] = index_settings body['mappings'] = doc_mapping if not es.indices.exists(index = index_name): print("create index") es.indices.create(index=index_name, body=body) time.sleep(2) else: print('index exists') doc1 = { 'name' : 'Elasticsearch Essentials', 'category' : ['Big Data', 'search engines', 'Analytics'], 'Publication' : 'Packt-Pub', 'Publishing Date' : '2015-31-12' } es.index(index=index_name, body=doc1, id='123') response = es.get(index=index_name, id='123', ignore=404) print(type(response), response['_source']) script ={"script" : "ctx._source.category.add(\"pytest1\")"} es.update(index=index_name, body=script, id='123') response = es.get(index=index_name, id='123', ignore=404) print(type(response), response['_source'])
python elasticsearch7.9
原创hjun169 博主文章分类:elasticsearch ©著作权
文章标签 elasticsearch python 文章分类 大数据
上一篇:presto java
-
Centos7.9 安装 ElasticSearch
r -zxvf elasticsearch-7.16.2-linux-x86_64.tar.gz 修改系统参数 修改系统参数的目的是确保系统有足够的资
elasticsearch Elastic 配置文件 -
CentOS 7.9安装python3.11
CentOS 7.9安装python3.11
centos python3.11 linux python Python -
CentOS 7.9 安装Docker
Docker简单介绍Docker的应用场景Web 应用的自动化打包和发布。自动化测试和持续集成、发布。在服务型环境中
docker redis 应用程序 客户端