Add mappings to an Elasticsearch index in realtime
来源:互联网 发布:nba2k16mc生涯数据 编辑:程序博客网 时间:2024/05/17 20:02
Changing mapping on existing index is not an easy task. You may find the reason and possible solutions in here:
http://www.elasticsearch.org/blog/changing-mapping-with-zero-downtime/
to get current mapping details, here is the sample code:
ClusterState cs = client.admin().cluster().prepareState().setFilterIndices("myIndex").execute().actionGet().getState();IndexMetaData imd = cs.getMetaData().index("myIndex")MappingMetaData mdd = imd.mapping("myType")
Put Mappings In Real time:
private void putMapping() { if (client != null) { if (client.admin().indices().prepareExists(IndexName).execute().actionGet().isExists()) { XContentBuilder mappings = null; try { mappings = XContentFactory.jsonBuilder().startObject() .startObject(INDEX_TYPE) .startObject("properties").startObject(FIELD_NAME) .field("type","string") .field("store","yes") .field("index", "analyzed") .field("analyzer", "simple").endObject() .endObject() .endObject().endObject(); } catch (IOException e) { e.printStackTrace(); } client.admin().indices().prepareClose(IndexName).execute().actionGet(); client.admin().indices().prepareDeleteMapping(IndexName).setType(INDEX_TYPE).execute().actionGet(); client.admin().indices().preparePutMapping(IndexName).setIgnoreConflicts(true).setType(INDEX_TYPE).setSource(mappings).execute().actionGet(); client.admin().indices().prepareOpen(IndexName).execute().actionGet(); } } else {throw new IllegalStateException(" Elastic Search not initialized properly.."); }}
- Add mappings to an Elasticsearch index in realtime
- HBaseCon 2013: Using Coprocessors to Index Columns in an Elasticsearch Cluster
- Add text to an image in Java
- what is an elasticsearch index?
- Add formatting to the cell in an Excel document
- How to Add An Automatically Executable Program in YOCTO?
- git add to index 无效
- [ElasticSearch] mappings and type
- Elasticsearch mappings小结
- ElasticSearch(Settings,Mappings)
- How to add an AJAX cart in the header in OpenCart
- Is there a way to add a badge to an application icon in Android?
- Github:failed to add file / to index
- ORA-14452: attempt to create, alter or drop an index on temporary table already in use
- ORA-14452: attempt to create, alter or drop an index on temporary table already in use
- How to implement realtime periodic tasks in Linux applications
- Using Imagecache and CCK Imagefield to Add an Image in Drupal
- Unable to register this add-in because its DllRegisterServer returns an error.
- 【伸展树篇】我仍旧不记得那天参考的代码---存父节点的Splay树
- UVa 10316 - Airline Hub
- Hyper-V 虚拟机与主机共享文件
- ASP.NET几种清除页面缓存的方法
- Elasticsearch template configuration
- Add mappings to an Elasticsearch index in realtime
- COCOS2D-X 关于 fatal error C1083: 无法打开包括文件:“CCStdC.h” 的问题(同时避免copy文件夹和库)
- dropdownlist 的动态生成
- Maven 初学(一)基本概念
- Ubuntu 12.04X64 安装Nodejs
- JSP中包含外部文件的方式
- 携着往事的深沉,
- 远。时间;可
- my.cnf优化