【发布时间】:2016-08-17 14:43:41
【问题描述】:
我是弹性搜索的新手,过去几天我一直在试验它。我无法进行正确的映射,因为我在映射中提到的所有数据类型都被映射到类型“word”而不是相应的类型。这是我做的映射
POST my_index
{
"settings" : {
"analysis" : {
"analyzer" : {
"lowercase_analyzer" : {
"type" : "custom",
"tokenizer" : "keyword",
"filter" : ["lowercase"]
}
}
}
},
"mappings" : {
"my_type" : {
"properties" : {
"name" : {"type" : "string" ,"index" : "not_analyzed" },
"field0" : {
"properties" : {
"field1" : {"type" : "boolean" },
"field2" : {"type" : "string" },
"field3" : {"type" : "date", "format" : "yyyy-MM-dd HH:mm:ss SSSSSS" }
}
}
}
}
}
}
为了测试映射,我使用“_analyze”api如下
GET my_index/_analyze
{
"field" : "name",
"text" : "10.90.99.6"
}
这给了我以下结果
{
"tokens": [
{
"token": "10.90.99.6",
"start_offset": 0,
"end_offset": 10,
"type": "word",
"position": 0
}
]
}
我希望结果中的“类型”是“字符串”。但是我不明白为什么它返回“word”类型。当我使用 _analyze api 在嵌套字段中发布布尔或时间戳类型的数据时,其他字段也会发生同样的情况。
GET my_index/_analyze
{
"field" : "field0.field1",
"text" : "true"
}
结果
{
"tokens": [
{
"token": "true",
"start_offset": 0,
"end_offset": 4,
"type": "word",
"position": 0
}
]
}
我的映射哪里做错了。
另外,elastic search reference api 中没有这样的“单词”数据类型。
【问题讨论】:
标签: elasticsearch