根据编号查询
GET custom/_search
{
"query": {
"term": {
"no": "abc"
}
}
}
查询指定的列
GET custom/_search
{
"_source": ["id", "no"],
"size": 10000,
"query": {
"ids": {
"values": [
1419623, 1419622, 1419621
]
}
}
}
根据id删除
POST /custom/_delete_by_query
{
"query": {
"terms": {
"_id": [21151]
}
}
}
根据id修改某记录的值
POST /custom/_update/13878794
{
"doc": {
"playTime": null
}
}
根据id将某记录的个别字段值删除
POST /custom/_update/13878794
{
"script": {
"source": "ctx._source.remove('playTime')"
}
}
查询索引结构
GET /custom
GET /custom/_mapping
完整索引创建
PUT /my_index
{
"settings": {
"number_of_shards": 3,
"number_of_replicas": 1
},
"mappings": {
"properties": {
"user_id": { "type": "long" },
"content": { "type": "text", "analyzer": "ik_max_word" },
"created_at": { "type": "date" }
}
}
}
PUT /{index_name}
{
"settings": { ... }, # 索引的配置(分片、副本等)
"mappings": { ... }, # 字段类型和属性定义
"aliases": { ... } # 可选,索引别名
}
更新映射(仅允许新增字段)
PUT /{index_name}/_mapping { "properties": { "new_field": { "type": "keyword" } } }
3.2 修改设置(如副本数)
PUT /{index_name}/_settings { "index": { "number_of_replicas": 2 } }