#ik分词器两种方式
GET _analyze
{
"analyzer": "ik_smart",
"text": "超级喜欢张小明"
}
GET _analyze
{
"analyzer": "ik_max_word",
"text": "超级喜欢张小明"
}
#索引的基本操作
#添加
PUT /test1/type1/1
{
"name":"张三",
"age":3
}
#建索引和字段
PUT /test2
{
"mappings": {
"properties": {
"name":{
"type": "text"
},
"age":{
"type": "long"
},"birthday":{
"type": "date"
}
}
}
}
GET test2
GET test1
GET _cat/indices?v
#修改
#以前的方法,PUT如果不传递值就会覆盖
PUT /test1/type1/1
{
"name":"张三13",
"age":3
}
#现在的方式
POST /test1/type1/1/_update
{
"doc":{
"name":"张三14"
}
}
#删除索引
DELETE /test2
PUT /test3/type1/4
{
"name":"张三",
"age":23,
"desc":"测试4",
"tags":["插画1","阳光","虎"]
}
#查询
GET /test3/type1/1
GET /test3/type1/_search?q=age:39
GET /test3/type1/_search
{
"query": {
"match": {
"desc": "测试"
}
},
"_source": ["name","desc"],
"sort": [
{
"age": {
"order": "desc"
}
}
],
"from": 0, "size": 2
}
#多条件查询
GET /test3/type1/_search
{
"query": {
"bool": {
"must": [
{
"match": {
"name": "张三"
}
},{
"match": {
"age": "23"
}
}
]
}
}
}
#查询索引的全部文档
GET molv_index/_doc/_search
{
"query": {"match_all": {}}
}
must 类似and
should 类似or
must_not 类似 not