热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

markdownElasticsearch:更新现有索引的映射和设置

本文由编程笔记#小编为大家整理,主要介绍了markdownElasticsearch:更新现有索引的映射和设置相关的知识,希望对你有一定的参考价值。
本文由编程笔记#小编为大家整理,主要介绍了markdown Elasticsearch:更新现有索引的映射和设置相关的知识,希望对你有一定的参考价值。




# Elasticsearch: updating the mappings and settings of an existing index
*Note: This was written using elasticsearch 0.9.*
[Elasticsearch](http://www.elasticsearch.org/) will automatically create an index (with basic settings and mappings) for you if you post a first document:
```bash
$ curl -X POST 'http://localhost:9200/thegame/weapons/1' -d \
'{
"_id": 1,
"name": "Longsword",
"description": "The Longsword can be wielded in one or two hands and is also known as a Bastard Sword. It combines power, speed and reach to become one of the most well rounded weapons.",
"category": "Sharp"
}'
```
You can see the settings (for the index) and mapping (for the `weapons` type) with:
```bash
$ curl -X GET 'http://localhost:9200/thegame/_settings'
$ curl -X GET 'http://localhost:9200/thegame/weapons/_mapping'
```
To **update the settings**, if you're defining new analyzers or filters, you first need to `_close` the index, then `_open` it when done updating:
```bash
$ curl -X POST 'http://localhost:9200/thegame/_close'
$ curl -X PUT 'http://localhost:9200/thegame/_settings' -d \
'{
"analysis": {
"analyzer": {
"full_name": {
"filter": [
"standard",
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "standard"
}
}
}
}'
$ curl -X POST 'http://localhost:9200/thegame/_open'
```
To **update the mappings** of this existing index, you need to do it for each type (here we only have the `weapons` type):
```bash
$ curl -X PUT 'http://localhost:9200/thegame/weapons/_mapping?ignore_cOnflicts=true' -d \
'{
"weapons": {
"properties": {
"name": {
"type": "string",
"analyzer": "full_name"
},
"description": {
"type": "string"
},
"category": {
"type": "string"
}
}
}
}'
```
You can do all of this at once if you delete then re-create your index, but you will **loose all stored documents**, so you will have to reload them. But sometimes for big changes to mapping/settings, this makes more sense:
```bash
$ curl -X DELETE 'http://localhost:9200/thegame'
$ curl -X POST 'http://localhost:9200/thegame' -d \
'{
"mappings": {
"weapons": {
"properties": {
"name": {
"type": "string",
"analyzer": "full_name"
},
"description": {
"type": "string"
},
"category": {
"type": "string"
}
}
}
},
"settings": {
"analysis": {
"analyzer": {
"full_name": {
"filter": [
"standard",
"lowercase",
"asciifolding"
],
"type": "custom",
"tokenizer": "standard"
}
}
}
}
}'
```


推荐阅读
  • 本文详细介绍了如何在Linux系统上安装和配置Smokeping,以实现对网络链路质量的实时监控。通过详细的步骤和必要的依赖包安装,确保用户能够顺利完成部署并优化其网络性能监控。 ... [详细]
  • 本文详细介绍了 Dockerfile 的编写方法及其在网络配置中的应用,涵盖基础指令、镜像构建与发布流程,并深入探讨了 Docker 的默认网络、容器互联及自定义网络的实现。 ... [详细]
  • 使用GDI的一些AIP函数我们可以轻易的绘制出简 ... [详细]
  • PostgreSQL 10 离线安装指南
    本文详细介绍了如何在无法联网的服务器上进行 PostgreSQL 10 的离线安装,并涵盖了从下载安装包到配置远程访问的完整步骤。 ... [详细]
  • 本文将介绍如何编写一些有趣的VBScript脚本,这些脚本可以在朋友之间进行无害的恶作剧。通过简单的代码示例,帮助您了解VBScript的基本语法和功能。 ... [详细]
  • Android 渐变圆环加载控件实现
    本文介绍了如何在 Android 中创建一个自定义的渐变圆环加载控件,该控件已在多个知名应用中使用。我们将详细探讨其工作原理和实现方法。 ... [详细]
  • 解读MySQL查询执行计划的详细指南
    本文旨在帮助开发者和数据库管理员深入了解如何解读MySQL查询执行计划。通过详细的解析,您将掌握优化查询性能的关键技巧,了解各种访问类型和额外信息的含义。 ... [详细]
  • 扫描线三巨头 hdu1928hdu 1255  hdu 1542 [POJ 1151]
    学习链接:http:blog.csdn.netlwt36articledetails48908031学习扫描线主要学习的是一种扫描的思想,后期可以求解很 ... [详细]
  • MySQL 数据库迁移指南:从本地到远程及磁盘间迁移
    本文详细介绍了如何在不同场景下进行 MySQL 数据库的迁移,包括从一个硬盘迁移到另一个硬盘、从一台计算机迁移到另一台计算机,以及解决迁移过程中可能遇到的问题。 ... [详细]
  • 本文介绍如何在现有网络中部署基于Linux系统的透明防火墙(网桥模式),以实现灵活的时间段控制、流量限制等功能。通过详细的步骤和配置说明,确保内部网络的安全性和稳定性。 ... [详细]
  • 本文基于刘洪波老师的《英文词根词缀精讲》,深入探讨了多个重要词根词缀的起源及其相关词汇,帮助读者更好地理解和记忆英语单词。 ... [详细]
  • 本文详细介绍了如何使用 Yii2 的 GridView 组件在列表页面实现数据的直接编辑功能。通过具体的代码示例和步骤,帮助开发者快速掌握这一实用技巧。 ... [详细]
  • 使用 Azure Service Principal 和 Microsoft Graph API 获取 AAD 用户列表
    本文介绍了一段通用代码示例,该代码不仅能够操作 Azure Active Directory (AAD),还可以通过 Azure Service Principal 的授权访问和管理 Azure 订阅资源。Azure 的架构可以分为两个层级:AAD 和 Subscription。 ... [详细]
  • 机器学习中的相似度度量与模型优化
    本文探讨了机器学习中常见的相似度度量方法,包括余弦相似度、欧氏距离和马氏距离,并详细介绍了如何通过选择合适的模型复杂度和正则化来提高模型的泛化能力。此外,文章还涵盖了模型评估的各种方法和指标,以及不同分类器的工作原理和应用场景。 ... [详细]
  • 本文详细介绍了Python编程语言的学习路径,涵盖基础语法、常用组件、开发工具、数据库管理、Web服务开发、大数据分析、人工智能、爬虫开发及办公自动化等多个方向。通过系统化的学习计划,帮助初学者快速掌握Python的核心技能。 ... [详细]
author-avatar
Cindy_J_Lee
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有