elasticsearch

创建索引库
put ::http://127.0.0.1:9200/people

{
“settings”: {
“number_of_shards”: 3,
“number_of_replicas”: 1
},
“mappings”: {
“properties”: {
“name”: {
“type”: “text”
},
“age”: {
“type”: “integer”
}
}
}
}

创建文档

post::http://127.0.0.1:9200/people/_doc/8
{
“name” : “陈培根”,
“age” : 21
}

搜索文档
get ::http://127.0.0.1:9200/people/_doc/8

post::http://127.0.0.1:9200/people/_doc/_search
{
“query” : {
“term” : {
“name” : “陈”
}
}
}

post:: http://127.0.0.1:9200/people/_doc/_search

{
“query” : {
“query_string” : {
“default_field” : “name”,
“query” : “培根”
}
}
}

post http://127.0.0.1:9200/_analyze
{
“analyzer”: “ik_smart”,
“text”: “没有安装分词器时可以正常启动我非常不是喜欢你”
}

添加映射
post http://127.0.0.1:9200/people/_mapping

{
“properties”: {
“name1”: {
“type”: “text”
},
“age”: {
“type”: “integer”
}
}
}
查询映射
http://127.0.0.1:9200/people/_mapping

自动使用ik分词器
elasticsearchelasticsearch
index:true 可以搜索
store:true 再保存一份