es 创建索引报错_ES搜索引擎基本操作

一.创建索引库

执行:

,索引库的名称为zhen

结果(我已经创建过了,重复执行会报错):

二.创建索引

1.添加索引

2.添加索引(动态添加新列)

3.添加指定id的索引【根据id可以直接修改一前的索引】

三.搜索

1.根据id搜索

2.根据字段搜索【每一个_source对应一条索引】

3.多条件组合搜索

[[email protected] ~]# curl -H "Content-Type: application/json" -XGET http://192.168.245.133:9200/zhen/employee/_search?pretty -d ‘

> {

> "query":

> {"multi_match":

> {

> "query":"bin",

> "fields":["last_name","first_name"],

> "operator":"and"

> }

> }

> }‘

{

"took" : 32,

"timed_out" : false,

"_shards" : {

"total" : 5,

"successful" : 5,

"skipped" : 0,

"failed" : 0

},

"hits" : {

"total" : 3,

"max_score" : 0.6099695,

"hits" : [

{

"_index" : "zhen",

"_type" : "employee",

"_id" : "1",

"_score" : 0.6099695,

"_source" : {

"first_name" : "god bin",

"last_name" : "pang",

"age" : 40,

"about" : "I love to go rock climbing",

"interests" : [

"sports",

"music"

]

}

},

{

"_index" : "zhen",

"_type" : "employee",

"_id" : "Nsigx2gBJyzNsh6L2KV0",

"_score" : 0.2876821,

"_source" : {

"first_name" : "bin",

"age" : 33,

"about" : "I love to go rock climbing",

"interests" : [

"sports",

"music"

]

}

},

{

"_index" : "zhen",

"_type" : "employee",

"_id" : "7cikx2gBJyzNsh6LwqUg",

"_score" : 0.2876821,

"_source" : {

"first_name" : "bin",

"age" : 33,

"about" : "I love to go rock climbing",

"interests" : [

"sports",

"music"

]

}

}

]

}

}

四.修改配置

执行:curl -H "Content-Type: application/json" -XPUT ‘http://192.168.245.133:9200/zhen/‘ -d‘{"settings":{"number_of_replicas":2}}‘修改副本数

注意:不能在创建索引之后修改配置!

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值