基本使用
1.添加索引 (设置索引默认ik分词器)
7.x版本 type废除
PUT test_db
{
"settings": {
"analysis": {
"analyzer": {
"default": {
"type": "ik_max_word"
}
}
}
}
}
1.1 指定字段设置分词器
PUT test_db
{
"properties": {
"字段": {
"type": "text",
"analyzer": "ik_max_word"
}
}
}
1.2查看分词结果
GET test_db/_analyze
{
"text":"小黑的电脑"
}
2.添加/修改数据(修改只需要更改json内容)
PUT test_db/_doc/3
{
"name":"小黑的电脑",
"age":"17",
"gender":"男"
}
3. 查询数据
GET test_db/_search
{
"query": {
"term": {
"name":"小黑"
}
}
}
4.删除索引
DELETE test_db