Elasticsearch简明学习(第一天)

工作相关和扩展核心能力的需要,采用较为简单的方法来学习Elasticsearch,作相关记录备查。

一、采用Docker安装

sudo docker pull elasticsearch:7.7.0
sudo docker images
sudo docker run --name elasticsearch -d -e ES_JAVA_OPTS="-Xms512m -Xmx512m" -e "discovery.type=single-node" -p 9200:9200 -p 9300:9300 elasticsearch:7.7.0

a4e6e652-3d83-4407-a72c-177292a22728

ed8445ca-6ed3-4bb8-937a-1aa46482d1a5

二、Curl进行测试

$ curl -XGET -u "elastic:changeme" 'http://localhost:9200/' -H 'Content-Type: application/json'
curl -XPUT 'http://localhost:9200/twitter/_doc/1?pretty' -H 'Content-Type: application/json' -d '
{
    "user": "kimchy",
    "post_date": "2009-11-15T13:12:00",
    "message": "Trying out Elasticsearch, so far so good?"
}'
curl -XPUT 'http://localhost:9200/twitter/_doc/2?pretty' -H 'Content-Type: application/json' -d '
{
    "user": "kimchy",
    "post_date": "2009-11-15T14:12:12",
    "message": "Another tweet, will it be indexed?"
}'
curl -XPUT 'http://localhost:9200/twitter/_doc/3?pretty' -H 'Content-Type: application/json' -d '
{
    "user": "elastic",
    "post_date": "2010-01-15T01:46:38",
    "message": "Building the site, should be kewl"
}'

三、python编写代码

使用python来写的话就是

fe577cc2-0059-434e-a089-5e5105607703

四、可能出错的问题

1、由于代码版本的错误,需要将https改成http

60e09548-4dbe-4261-ad49-f910993eb6fb

2、elasticsearch.ApiError: ApiError(406报错……

需要把elasticsearch安装版本和python Elasticsearch第三方库(模块)版本保持一致就可以解决。

重要参考资料:

Elastic 中国社区官方博客_Elastic,Elasticsearch,Kibana-CSDN博客

posted on   jsxyhelu  阅读(23)  评论(0编辑  收藏  举报

相关博文:
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
历史上的今天:
2022-12-20 仿照“全能扫描王”的图像增强-由原理到实现
2022-12-20 OpenCV Forum学习(2022-12-20)

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示