标签:方便 ati 获取 keep 方法 size 过滤 analyzer get
DELETE /test
PUT /test
{
"settings": {
"number_of_shards": 10,
"number_of_replicas": 1
}
}
DELETE /employee
##非结构化新建索引
PUT /employee
{
"settings": {
"number_of_replicas": 1
, "number_of_shards": 1
}
}
PUT /employee/_doc/1
{
"name":"凯杰2",
"age":30
}
PUT /employee/_doc/1
{
"name":"凯杰3"
}
##获取索引记录
GET /employee/_doc/1
#指定字段修改
POST /employee/_update/1
{
"doc": {
"name":"凯杰4"
}
}
#强制指定创建,若已经存在则失败
POST /employee/_create/6
{
"name":"兄长2",
"age":"31"
}
#删除某个文档
DELETE /employee/_doc/2
#查询全部文档
GET /employee/_search
#使用结构化的方式创建索引
PUT /employee
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name":{"type":"text"},
"age":{"type": "integer"}
}
}
}
#不带条件查询所有记录的方法
GET /employee/_search
{
"query": {
"match_all": {}
}
}
#分页查询
GET /employee/_search
{
"query": {
"match_all": {}
}
, "from": 0,
"size": 2
}
#带关键字条件查询
GET /employee/_search
{
"query":{
"match": {
"name": "兄"
}
}
}
#带排序
GET /employee/_search
{
"query":{
"match": {
"name": "兄"
}
}, "sort":[
{"age":{"order":"asc"}}
]
}
#带filter term完全匹配 match 分词匹配
GET /employee/_search
{
"query": {
"bool": {
"filter": [
{"term":{"name":"兄111"}}
]
}
}
}
#带聚合
GET /employee/_search
{
"query": {
"match": {
"name": "兄"
}
},"sort": [
{
"age": {
"order": "desc"
}
}
],
"aggs": {
"group_by_age": {
"terms": {
"field": "age"
}
}
}
}
#新建一个索引
PUT /movie/_doc/1
{
"name":"Eating an apple a day & keeps the doctor away"
}
GET /movie/_search
{
"query": {
"match": {
"name": "appl"
}
}
}
#使用analyze api查看分词状态 过滤两次(1.量词,特殊字符 2.词干 英文会大写变小写方便查询)
GET /movie/_analyze
{
"field": "name",
"text":"Eating an apple a day & keeps the doctor away"
}
DELETE /movie
#使用结构化方式创建索引
PUT /movie
{
"settings": {
"number_of_shards": 1,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"name":{"type": "text","analyzer": "english"}
}
}
}
GET /movie/_search
#Text 被分析索引的字符串类型
#keyword不能被分析只能被精确匹配的字符串类型
#Date日期类型,可以配合format一起使用
#数字类型 long interger short double
#boolean true false
#Array one two
#Object json嵌套
#IP 类型
#Geo_point地址位置
标签:方便 ati 获取 keep 方法 size 过滤 analyzer get
原文地址:https://www.cnblogs.com/yaohaitao/p/12443435.html