全文搜索引擎ElasticSearch弹性搜索教程(二)简单插入数据(使用bash脚本语言)
发布日期:2021-05-14 14:12:14 浏览次数:16 分类:精选文章

本文共 2700 字,大约阅读时间需要 9 分钟。

������Elasticsearch������������������������������

���������������������������������������������������������Elasticsearch���������������������������������������������������������������������������������������������������������������������������������������

������������Elasticsearch

������Elasticsearch���������������������������������������������������������Elasticsearch���������������������������������������

./bin/elasticsearch -d

������������������������

������������������������������������������������������������������������

ps aux | grep elasticsearch

������������������ elasticsearch ���������������������Elasticsearch���������������������

������������������

���������������������������curl���������������������������������������������������������������������

  • ���������������csdn
  • ���������index���**���**people
  • ������ID���1
  • ���������name���age���profile���hobby

������������������������������������������������

curl -X PUT "localhost:9200/csdn/people/1?pretty" -H 'Content-Type: application/json' -d({
"name": "$2",
"age": "$3",
"profile": "$4",
"hobby": ["$5", "$6"]
})

���������������������������������������������������������������������

������������������������������������

���������������������������������������������������������������������������������������������������Bash���������������

#!/bin/bash
# ������������: sh 01-insert-data.sh ID name age profile hobby ...
# ������������������
if [[ $# -gt 1 ]]; then
ID=$1
name=$2
age=$3
profile=$4
hobby=$5
������="}"
if [[ $6 ]]; then hobby=','$6'; fi
if [[ $7 ]]; then hobby=','$7'; fi
data="{
\"name\": \"$name\",
\"age\": \"$age\",
\"profile\": \"$profile\",
\"hobby\": [${hobby}]
}"
curl -X PUT "localhost:9200/csdn/people/${ID}?pretty" -H 'Content-Type: application/json' -d ${data}
exit 0
fi

������������������������

������������������������������������������������������������������

curl -X GET "localhost:9200/csdn/people/1/_source

���������������JSON������������������������������������������������������������������������������ES ���������������

������������������������

  • ������������������������������������������������������������Elasticsearch������������������
  • ���������������������������������������������������������������������������������������������
  • ���������������������������������������������������������������������������������
  • ������������������������������ES���������������������������������
  • ������������������

    • ���������������������������������������Elasticsearch���restapi������CRUD���������
    • ���������������������������������������������Elasticsearch������������������������������������������������������

    ���������������������������������������������������

    上一篇:算法题:一排硬币,每个硬币的面额是随意的正整数,从两端任意取,怎么取到的面额最大(你看了能给别人讲)。
    下一篇:全文搜索引擎ElasticSearch弹性搜索教程(一)安装和简单搜索

    发表评论

    最新留言

    哈哈,博客排版真的漂亮呢~
    [***.90.31.176]2025年04月14日 05时10分45秒