ElasticSearch索引常用操作

添加索引

如果只是简单的使用索引,那么可以利用默认的设置。
如果响应自己手动编写复杂的索引,则可通过修改config/elasticsearch.yml文件
action.auto_create_index:false
来禁止自动创建索引。

创建索引使用PUT,如:

PUT /my_index
{
"settings": { ... },
"mappings": {
"type_one": { ... },
"type_two": { ... },
...
}

删除索引

删除索引使用DELETE ,如:
DELETE /index_one,index_two
DELETE /index_*

自定义索引

自定义索引时需要注意主分片和复制分片的设置。
number_of_shards
number_of_replicas
如下:

PUT /my_temp_index
{
    "settings": {
        "number_of_shards" : 1,
        "number_of_replicas" : 0
    }
}

分析器设置

PUT /spanish_docs
{
    "settings": {
        "analysis": {
            "analyzer": {
                "es_std": {
                    "type": "standard",
                    "stopwords": "_spanish_"
                }
            }
        }
    }
}
发布了79 篇原创文章 · 获赞 3 · 访问量 5252

猜你喜欢

转载自blog.csdn.net/SW_LCC/article/details/103071428