索引更改mappings
查询旧index的属性
GET indexName
将想留存的setting、mapping保留复制
创建新的index
PUT indexName_new
{
"mappings": {
"properties": {
"kind": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"title": {
"type": "text",
"fields": {
"keyword": {
"type": "keyword",
"ignore_above": 256
}
}
},
"authors":{
"type": "text",
"index": true,
"store": true
}
}
}
}
同步数据
POST _reindex
{
"source": {
"index": "indexName"
},
"dest": {
"index": "indexName_name"
}
}
删除旧索引
delete indexName
设置索引
POST _aliases
{
"actions": [
{
"add": {
"index": "indexName_new",
"alias": "index"
}
}
]
}
搜索
-- match
put url/index_name/_search
{
"query":{
"match":{
"property":""
}
}
}
-- termquery
put url/index_name/_search
{
"query": {
"term": {
"age": {
"value": 12
}
}
}
}
{
"query": {
"bool": {
"must": [
{
"term": {
"property": ""
}
}
]
}
}
}
更新属性值
post url/index_name/_update_by_query
{
"query": {
"bool": {
"must": [
{
"term": {
"property": ""
}
}
]
}
},
"script": {
"ctx._source['property'] = ''"
}
}