分类目录归档:ElasticSearch

[ Python使用ElasticSearch官方包 ]


1. 安装

  • pip install elasticsearch
  • pip install elasticsearch==7.13.1
  • 官方

2. 基本使用

参考文档 - 百度文档1 - 百度文档2 - 百度文档3

# from django.shortcuts import render
from elasticsearch import Elasticsearch
es = Elasticsearch(hosts=["http://localhost:9200"],
                   sniff_on_start=True, sniff_on_con

< Read more >

[ ElasticSearch基础 ]


Es基础操作

官方文档

Python的官方文档

前提条件

  1. 安装es
  2. kibana
  3. ik分词器

索引的操作

  • 相当于表

创建 修改(不允许) 判断是否存在 查询

# 创建索引
# PUT 索引名称
PUT test_index

# PUT 索引 不允许修改索引信息
# aliases 别名
PUT test_index_1
{
  "aliases": {
    "test1": {}
  }
}

# DELETE 删除索引
DELETE test_index_1



# HEAD索引 http状态码 200, 404
head test_i

< Read more >

[ Docker安装ElasticSearch和Kibana ]


Docker下安装ES 参考文档

一. 7.11.1版本

  1. 拉取Docker镜像
docker pull elasticsearch:7.11.1
  1. 启动镜像
docker run --name elasticsearch -p 9200:9200 -p 9300:9300 -e "discovery.type=single-node" -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -d elasticsearch:7.11.1
  1. 测试是否成功
http://localhost:9200
  1. 安装IK分词器 4.

< Read more >