我有一个JSON数据,当我索引数据时,它会通过弹性搜索自动映射 . 如何排除映射中的某些字段 . 我已经尝试手动定义 Map ,但是当我正在进行批量索引时,它会自动映射其他字段 .
恩 . 我的JSON数据看起来像这样
[
{
"id": "232",
"name": "Lorem",
"description": "Ipsum Dolor",
"image": [
{"key": "asadasd.jpg"},
{"key": "asasd2d.jpg"}
],
"is_active": true
},
...
我手动定义时的 Map
PUT myindex
{
"mappings": {
"product": {
"properties": {
"id": { "type": "text },
"name": { "type": "text"},
"description": { "type": "text" },
"is_active": { "type": "boolean" }
}
}
}
}
我想要实现的是数据仍然存在我只想排除不包含在索引中的图像属性 .
因此,当我在弹性搜索中查询时,我仍然获得带有图像的数据
那可能吗?
感谢你们 . 我是弹性搜索的新手
{
"id": "232",
"name": "Lorem",
"description": "Ipsum Dolor",
"image": [
{"key": "asadasd.jpg"},
{"key": "asasd2d.jpg"}
],
"is_active": true
}
1 回答
是的,只需将dynamic: false添加到您的映射即可,如下所示:
image
数组仍将在源中,但不会修改映射 .