网站左右箭头素材,泉州住房城乡建设局网站,中国机械加工网加热炉节能,wordpress仿站价格添加元数据服务
元数据服务就是对元数据提供存取功能的服务。元数据就是系统定义的基本信息#xff0c;比如一张相片的名字#xff0c;版本#xff0c;拍摄时间#xff0c;散列值等。客户端和接口服务之间根据对象的名字来引用一个对象#xff0c;一个对象可以有多个版本…添加元数据服务
元数据服务就是对元数据提供存取功能的服务。元数据就是系统定义的基本信息比如一张相片的名字版本拍摄时间散列值等。客户端和接口服务之间根据对象的名字来引用一个对象一个对象可以有多个版本除了删除标志外每个版本指向数据服务的一个实际的数据存储
ES的基本使用 ES或者任意的一个分布式数据库都可以作为元数据服务 启动windowselasticsearch-7.6.2-windows-x86_64\elasticsearch-7.6.2\bin\elasticsearch.bat 成功http://192.168.7.6:9200/people 链接服务器的golang操作
全文搜索引擎 Elasticsearch 入门教程 作者: 阮一峰 ES官方中文手册 添加索引
package mainimport (contextfmtgithub.com/olivere/elastic
)func main(){Client, err : elastic.NewClient(elastic.SetURL(http://192.168.7.6:9200))fmt.Println(Client, err)name : people2Client.CreateIndex(name).Do(context.Background())
}插入和查找
func main(){Client, err : elastic.NewClient(elastic.SetURL(http://192.168.7.6:9200))fmt.Println(Client, err)name : people2data : {name: wali,country: Chian,age: 30,date: 1987-03-07}_, err Client.Index().Index(name).Type(man1).Id(1).BodyJson(data).Do(context.Background())get, err : Client.Get().Index(name).Type(man1).Id(1).Do(context.Background())fmt.Println(get, err)ES的API访问curl
常用操作
浏览ES服务器
$ curl -XGET http://localhost:9200/
{name : DESKTOP-PVBHUQ5,cluster_name : elasticsearch,cluster_uuid : 79x294HmR3iDFIQ2M3-_Kg,version : {number : 7.6.2,build_flavor : default,build_type : zip,build_hash : ef48eb35cf30adf4db14086e8aabd07ef6fb113f,build_date : 2020-03-26T06:34:37.794943Z,build_snapshot : false,lucene_version : 8.4.0,minimum_wire_compatibility_version : 6.8.0,minimum_index_compatibility_version : 6.0.0-beta1},tagline : You Know, for Search
}插入索引
$curl -XPUT http://localhost:9200/people{acknowledged:true,shards_acknowledged:true,index:people}往索引库中新增数据
curl http://localhost:9200/people/ -XPOST -d {author : a, name:a} 查看集群健康状况
curl -XGET http://localhost:9200/_cluster/health?formatyaml
---
cluster_name: elasticsearch
status: yellow
timed_out: false
number_of_nodes: 1
number_of_data_nodes: 1
active_primary_shards: 3
active_shards: 3
relocating_shards: 0
initializing_shards: 0
unassigned_shards: 3
delayed_unassigned_shards: 0
number_of_pending_tasks: 0
number_of_in_flight_fetch: 0
task_max_waiting_in_queue_millis: 0
active_shards_percent_as_number: 50.0获取ES所有索引
$~curl -XGET http://localhost:9200/_cat/indices
yellow open people2 OIyNXAzwSvCXdRTM1OCcug 1 1 1 0 10.2kb 10.2kb
yellow open bigdata_p GlbTA7_xSVK26L_oU_pVKw 1 1 0 0 283b 283b
yellow open people AwsSuR6VS_uCfkNvqDxc6Q 1 1 0 0 283b 283b获取索引字段
C:\Users\HodgeKou curl -XGET http://localhost:9200/people2/_mapping?formatyaml
---
people2:mappings:properties:age:type: longcountry:type: textfields:keyword:type: keywordignore_above: 256date:type: datename:type: textfields:keyword:type: keywordignore_above: 256新建索引
curl -XPUT localhost:9200/people2删除索引
curl -XDELETE localhost:9200/people?formatyaml插入单条数据
curl -XPUT localhost:9200/people/external/1?formatyaml -d
quote { name:paxi}查询单条数据
curl -XGET localhost:9200/people2/_search?pretty删除单条数据
curl -XDELETE localhost:9200/people2/external/3?formatyaml
ES进行更新PUT请求时会重发数据
第一次PUT
$ curl -X PUT localhost:9200/accounts/person/1 -d
{user: 张三,title: 工程师,desc: 数据库管理
}
---------------------------------------------------
{_index:accounts,_type:person,_id:1,_version:1,result:created,_shards:{total:2,successful:1,failed:0},created:true
}第二次PUT更改了数据banben_version加1
$ curl -X PUT localhost:9200/accounts/person/1 -d
{user : 张三,title : 工程师,desc : 数据库管理软件开发
} ----------------------------------------------------
{----_index:accounts,_type:person,_id:1,_version:2,result:updated,_shards:{total:2,successful:1,failed:0},created:false
}
上面代码中我们将原始数据从数据库管理改成数据库管理软件开发。 返回结果里面有几个字段发生了变化。_version : 2,
result : updated,
created : false