col*_*nwr 5 mapping elasticsearch
我无法为"hashtags"创建自定义映射,"hashtags"是elasticsearch中"twitter_entities"的子字段.我尝试通过以下方式实现:
{
"mappings": {
"tweet" : {
"properties": {
"twitter_entities.hashtags" : {
"type" : "multi_field",
"fields" : {
"hashtag" : {
"type" : "string",
"analyzer" : "hashtag"
},
"autocomplete" : {
"type" : "string",
"index_analyzer" : "hashtag_autocomplete",
"search_analyzer" : "hashtag"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
这会创建另一个名为"twitter_entities.hashtags"的根域
{
"mappings": {
"tweet" : {
"properties": {
"hashtags" : {
"type" : "multi_field",
"fields" : {
"hashtag" : {
"type" : "string",
"analyzer" : "hashtag"
},
"autocomplete" : {
"type" : "string",
"index_analyzer" : "hashtag_autocomplete",
"search_analyzer" : "hashtag"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
和
{
"mappings": {
"tweet" : {
"properties": {
"_parent" : {"type" : "twitter_entities" },
"hashtags" : {
"type" : "multi_field",
"fields" : {
"hashtag" : {
"type" : "string",
"analyzer" : "hashtag"
},
"autocomplete" : {
"type" : "string",
"index_analyzer" : "hashtag_autocomplete",
"search_analyzer" : "hashtag"
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
两者都只是创建另一个名为"hashtags"的根域.
我无法在elasticsearch api或论坛中找到有关此操作的任何文档.有人能指出我正确的方向吗?
jav*_*nna 10
查看映射文档,尤其是有关对象类型的页面.您只需定义twitter_entities为一个对象并声明其字段properties,就像您对根对象(twitter_entities)所做的那样.您可以省略该类型,object因为任何包含其他字段的字段都会properties被检测为对象.
{
"mappings": {
"tweet" : {
"properties": {
"twitter_entities" : {
"type": "object",
"properties" : {
"hashtag" : {
"type" : "multi_field",
"fields" : {
"hashtag" : {
"type" : "string",
"analyzer" : "hashtag"
},
"autocomplete" : {
"type" : "string",
"index_analyzer" : "hashtag_autocomplete",
"search_analyzer" : "hashtag"
}
}
}
}
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3279 次 |
| 最近记录: |