一.創建索引庫
執行:,索引庫的名稱為zhen
結果(我已經創建過了,重復執行會報錯):
二.創建索引
1.添加索引
2.添加索引(動態添加新列)
3.添加指定id的索引【根據id可以直接修改一前的索引】
三.搜索
1.根據id搜索
2.根據字段搜索【每一個_source對應一條索引】
3.多條件組合搜索
[root@zhen ~]# 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}}'修改副本數
注意:不能在創建索引之后修改配置!
五.查看