elasticsearch - 如何将(文本)字段添加到 pgsync / elasticsearch 中的所有字段?
问题描述
我正在探索pgsync为某些表添加弹性搜索支持,但是,我希望能够将所有文本字段复制到一个“全部”字段。Elastic 以映射到组字段的形式对此提供支持copy-to
,请参见此处
像这样:
PUT my-index-000001
{
"mappings": {
"properties": {
"first_name": {
"type": "text",
"copy_to": "full_name"
},
"last_name": {
"type": "text",
"copy_to": "full_name"
},
"full_name": {
"type": "text"
}
}
}
}
如何在 PGSync schema.json 中实现这个组字段?
解决方案
您可以通过创建transform
具有类型的节点在 pgsync 中执行此操作mapping
。这是此处定义的书籍示例如何实现此目的的示例
[
{
"database": "book",
"index": "book",
"nodes": {
"table": "book",
"columns": [
"id",
"isbn",
"title",
"description"
],
"transform": {
"mapping": {
"title": {
"type": "text",
"copy_to": "full_name"
},
"description": {
"type": "text",
"copy_to": "full_name"
},
"full_name": {
"type": "text"
}
}
}
}
}
]
推荐阅读
- reactjs - Lunr - gatsby-plugin-lunr - 我可以在构建时更改数据/索引吗?
- javascript - 编写一个函数“giveMeRandom”,它接受一个数字 n 并返回一个包含 0 到 10 之间的 n 个随机数的数组
- sql - 如何将同一表中不同日期的行连接起来
- string - 调用 fmt.Printf("%+v", obj) 时如何自定义结构的特定字段的文本
- powershell - 将日期转换为 unixt 时间戳 - powershell
- python - python - 如何在没有do while的情况下在python循环的末尾而不是在循环的开头进行迭代?
- javascript - JS 按钮会减慢我的表格生成速度吗?
- c - 初始化结构数组时出现分段错误
- android - 注册不包含子域的 Android 深层链接路径
- flutter - Flutter 中的 FCM 后台处理 - iOS