【问题标题】:How to add (text)fields to all field in pgsync / elasticsearch?如何将(文本)字段添加到 pgsync / elasticsearch 中的所有字段?
【发布时间】:2021-09-22 15:46:01
【问题描述】:

我正在探索pgsync 为某些表添加弹性搜索支持,但是,我希望能够将所有文本字段复制到一个“全部”字段。 Elastic 以映射到组字段的形式对此提供支持,使用 copy-to,请参阅 here

像这样:

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 中实现这个组字段?

【问题讨论】:

    标签: elasticsearch mapping schema pgsync


    【解决方案1】:

    您可以在 pgsync 中通过使用 mapping 创建一个 transform 节点来执行此操作 类型。 这是一个示例,说明如何为定义的书籍示例here

    [
        {
            "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"
                        }
                    }
                }
            }
        }
    ]
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-07-04
      • 1970-01-01
      • 2013-10-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多