我想为我的索引更新elasticsearch中的默认映射。但是所有的文档都指出,我们必须提供更新映射的类型。问题是我有很多索引类型,并且它们是在出现新类型的文档时动态创建的。所以处理的最佳方式是默认映射类型。因为我不必为每种类型定义映射。但现在我无法更新我的索引默认映射。如果有可能请让我知道?更新elasticsearch中的默认索引映射
0
A
回答
0
我用default mapping如下:
我创建索引,指定_default_
映射。在这种情况下,我只有一个单一的领域,但我想,以确保它不会分析(这样我就可以跨类型做小面,说):
curl -XDELETE "http://localhost:9200/test_index"
curl -XPUT "http://localhost:9200/test_index" -d'
{
"mappings": {
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}'
然后,我创建了几个文件,每一个不同的类型:
curl -XPUT "http://localhost:9200/test_index/doc_type1/1" -d'
{ "title": "some text" }'
curl -XPUT "http://localhost:9200/test_index/doc_type2/2" -d'
{ "title": "some other text" }'
因此,对于每种类型映射将被动态地产生,并且将包括用于"title"
默认映射。我们可以通过查看映射看到这一点:
curl -XGET "http://localhost:9200/test_index/_mapping"
...
{
"test_index": {
"mappings": {
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
},
"doc_type2": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
},
"doc_type1": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
}
}
}
}
}
}
如果我刻面的title
场我会找回我的期望:
curl -XPOST "http://localhost:9200/test_index/_search" -d'
{
"size": 0,
"facets": {
"title_values": {
"terms": {
"field": "title",
"size": 10
}
}
}
}'
...
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"failed": 0
},
"hits": {
"total": 2,
"max_score": 0,
"hits": []
},
"facets": {
"title_values": {
"_type": "terms",
"missing": 0,
"total": 2,
"other": 0,
"terms": [
{
"term": "some text",
"count": 1
},
{
"term": "some other text",
"count": 1
}
]
}
}
}
这里是我使用的代码:
http://sense.qbox.io/gist/05c503ce9ea841ca4013953b211e00dadf6f1549
这是回答您的问题吗?
编辑:这里是你如何可以更新_default_
映射现有索引:(我用Elasticsearch版本1.3.4这个答案,顺便说一句)
curl -XPUT "http://localhost:9200/test_index/_default_/_mapping" -d'
{
"_default_": {
"properties": {
"title": {
"type": "string",
"index": "not_analyzed"
},
"name": {
"type": "string",
"index": "not_analyzed"
}
}
}
}'
相关问题
- 1. 设置默认映射Elasticsearch
- 2. ElasticSearch字段在索引时默认映射为字符串
- 3. 更新ElasticSearch映射
- 4. 通过更新索引模板更新Elasticsearch映射
- 5. 如何将文档批量索引到ElasticSearch的默认映射中?
- 6. 更新映射在我的索引(elasticsearch 1.4)
- 7. Elasticsearch默认映射嵌套领域
- 8. 将当前索引复制到新索引以使用更新后的映射/索引模板(ElasticSearch)
- 9. Elasticsearch 2.x索引映射_id
- 10. 更改elasticsearch映射
- 11. Elasticsearch更新索引模板
- 12. JacksonJaxbJsonProvider默认的objectmapper映射
- 13. 无法更改映射ElasticSearch
- 14. ElasticSearch:仅索引映射中指定的字段
- 15. 玩笑ElasticSearch搜索API映射命中
- 16. 为elasticsearch中的所有索引创建默认索引模板5.2
- 17. 将现有ElasticSearch索引重新索引到更新的模板
- 18. ElasticSearch映射Charfilter
- 19. Elasticsearch映射
- 20. ElasticSearch geo_shape映射
- 21. 映射在elasticsearch
- 22. 为什么在Elasticsearch中创建索引时这个新映射不起作用?
- 23. Elasticsearch重新索引
- 24. 在不删除映射的情况下删除Elasticsearch索引
- 25. Elasticsearch:使用映射到索引1场不同的方式
- 26. 如何为Elasticsearch映射/索引嵌套的Twitter数据(json)
- 27. 使用映射创建索引时的ElasticSearch异常(嵌套5.2.0)
- 28. servlet映射到默认/ tomcat中
- 29. 在ElasticSearch中重新索引索引以更改分片数量
- 30. 更改aws kibana的Elasticsearch映射