为什么在 Elasticsearch 中创建索引时这个新的映射没有生效?
Why is this new mapping not taking effect when creating index in Elasticsearch?
我正在使用 elasticsearch 1.5.0。
我按以下方式创建了一个新索引并将一些推文下载到新索引中 OK,但是当我查看实际映射时它并没有使用这个映射,但似乎试图弄清楚映射本身。我在这里做错了什么?
curl -XPUT 'http://localhost:9200/tweets' -d '
{
"tweets" : {
"mappings" : {
"tweet" : {
"properties" : {
"created_at" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss"
},
"day" : {
"type" : "integer"
},
"favorite_count" : {
"type" : "integer"
},
"hashtags" : {
"properties" : {
"indices" : {
"type" : "integer"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "standard"
}
}
},
"id_str" : {
"type" : "long"
},
"in_reply_to_screen_name" : {
"type" : "string",
"index" : "not_analyzed"
},
"month" : {
"type" : "integer"
},
"screen_name" : {
"type" : "string",
"index" : "not_analyzed"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "standard"
},
"urls" : {
"properties" : {
"display_url" : {
"type" : "string"
},
"expanded_url" : {
"type" : "string",
"index" : "not_analyzed"
},
"indices" : {
"type" : "long"
},
"url" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"user_mentions" : {
"properties" : {
"id" : {
"type" : "long"
},
"id_str" : {
"type" : "long"
},
"indices" : {
"type" : "long"
},
"name" : {
"type" : "string",
"index" : "not_analyzed"
},
"screen_name" : {
"type" : "string",
"index" : "not_analayzed"
}
}
},
"year" : {
"type" : "integer"
}
}
}
}
}
}'
当我测试将一些推文下载到索引中并检查映射时,我得到:
curl -XGET 'localhost:9200/tweets/_mapping/tweet?pretty'
{
"tweets" : {
"mappings" : {
"tweet" : {
"properties" : {
"created_at" : {
"type" : "string"
},
"day" : {
"type" : "string"
},
"favorite_count" : {
"type" : "long"
},
"hashtags" : {
"properties" : {
"indices" : {
"type" : "long"
},
"text" : {
"type" : "string"
}
}
},
"id_str" : {
"type" : "string"
},
"in_reply_to_screen_name" : {
"type" : "string"
},
"month" : {
"type" : "string"
},
"screen_name" : {
"type" : "string"
},
"text" : {
"type" : "string"
},
"urls" : {
"properties" : {
"display_url" : {
"type" : "string"
},
"expanded_url" : {
"type" : "string"
},
"indices" : {
"type" : "long"
},
"url" : {
"type" : "string"
}
}
},
"user_mentions" : {
"properties" : {
"id" : {
"type" : "long"
},
"id_str" : {
"type" : "string"
},
"indices" : {
"type" : "long"
},
"name" : {
"type" : "string"
},
"screen_name" : {
"type" : "string"
}
}
},
"year" : {
"type" : "string"
}
}
}
}
}
}
当我检查索引推文的映射时,在我将任何推文索引到其中之前,我得到以下结果:
curl -XGET 'localhost:9200/tweets/_mapping?pretty'
{
"tweets" : {
"mappings" : { }
}
}
您是否注意到 post 尝试创建索引时返回的错误? "screen_name" 下有 "not_analayzed"。将其更改为 "not_analyzed" 就可以了。
我正在使用 elasticsearch 1.5.0。
我按以下方式创建了一个新索引并将一些推文下载到新索引中 OK,但是当我查看实际映射时它并没有使用这个映射,但似乎试图弄清楚映射本身。我在这里做错了什么?
curl -XPUT 'http://localhost:9200/tweets' -d '
{
"tweets" : {
"mappings" : {
"tweet" : {
"properties" : {
"created_at" : {
"type" : "date",
"format" : "yyyy-MM-dd HH:mm:ss"
},
"day" : {
"type" : "integer"
},
"favorite_count" : {
"type" : "integer"
},
"hashtags" : {
"properties" : {
"indices" : {
"type" : "integer"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "standard"
}
}
},
"id_str" : {
"type" : "long"
},
"in_reply_to_screen_name" : {
"type" : "string",
"index" : "not_analyzed"
},
"month" : {
"type" : "integer"
},
"screen_name" : {
"type" : "string",
"index" : "not_analyzed"
},
"text" : {
"type" : "string",
"index" : "analyzed",
"analyzer" : "standard"
},
"urls" : {
"properties" : {
"display_url" : {
"type" : "string"
},
"expanded_url" : {
"type" : "string",
"index" : "not_analyzed"
},
"indices" : {
"type" : "long"
},
"url" : {
"type" : "string",
"index" : "not_analyzed"
}
}
},
"user_mentions" : {
"properties" : {
"id" : {
"type" : "long"
},
"id_str" : {
"type" : "long"
},
"indices" : {
"type" : "long"
},
"name" : {
"type" : "string",
"index" : "not_analyzed"
},
"screen_name" : {
"type" : "string",
"index" : "not_analayzed"
}
}
},
"year" : {
"type" : "integer"
}
}
}
}
}
}'
当我测试将一些推文下载到索引中并检查映射时,我得到:
curl -XGET 'localhost:9200/tweets/_mapping/tweet?pretty'
{
"tweets" : {
"mappings" : {
"tweet" : {
"properties" : {
"created_at" : {
"type" : "string"
},
"day" : {
"type" : "string"
},
"favorite_count" : {
"type" : "long"
},
"hashtags" : {
"properties" : {
"indices" : {
"type" : "long"
},
"text" : {
"type" : "string"
}
}
},
"id_str" : {
"type" : "string"
},
"in_reply_to_screen_name" : {
"type" : "string"
},
"month" : {
"type" : "string"
},
"screen_name" : {
"type" : "string"
},
"text" : {
"type" : "string"
},
"urls" : {
"properties" : {
"display_url" : {
"type" : "string"
},
"expanded_url" : {
"type" : "string"
},
"indices" : {
"type" : "long"
},
"url" : {
"type" : "string"
}
}
},
"user_mentions" : {
"properties" : {
"id" : {
"type" : "long"
},
"id_str" : {
"type" : "string"
},
"indices" : {
"type" : "long"
},
"name" : {
"type" : "string"
},
"screen_name" : {
"type" : "string"
}
}
},
"year" : {
"type" : "string"
}
}
}
}
}
}
当我检查索引推文的映射时,在我将任何推文索引到其中之前,我得到以下结果:
curl -XGET 'localhost:9200/tweets/_mapping?pretty'
{
"tweets" : {
"mappings" : { }
}
}
您是否注意到 post 尝试创建索引时返回的错误? "screen_name" 下有 "not_analayzed"。将其更改为 "not_analyzed" 就可以了。