couchdb - 通过 CouchDB-River 将字段排除在 Elasticsearch 索引之外

标签 couchdb elasticsearch

我正在使用 CouchDB-River 插件为 ealsticsearch 编制索引。目前我正在尝试实现用户搜索,其中简化的文档看起来像这样:

{
  username: "john",
  firstname: "John",
  lastname: "Doe",
  email: "john.doe@example.com",
  password: "someHash"
}

我不希望在 ES 中为密码编制索引,因为我看不到这样做有任何用处,但也许我在这里错了(我对 ES 还很陌生)?

我确实通过执行设置了 River:

curl -XPUT 'http://localhost/_river/st_user/_meta' -d '{
  "type" : "couchdb",
  "couchdb" : {
    "host" : "localhost",
    "port" : 5984,
    "db" : "sportstracker_usertest",
    "ignore_attachments":true,
    "filter" : null
    }
  },
  "index" : {
    "index" : "tracker",
    "type" : "user",
    "bulk_size" : "100",
    "bulk_timeout" : "10ms"
  }
}'

能不能通过River(Script Filters)或者ES的映射来实现?

最佳答案

根据 Elasticsearch's CouchDB river documentation

{
  "type" : "couchdb",
  "couchdb" : {
    "host" : "localhost",
    "port" : 5984,
    "db" : "sportstracker_usertest",
    "ignore_attachments":true,
    "filter" : "NAME_OF_FILTER_IN_COUCHDB",
    "filter_params" : {
      "FIRST_PARAMETER_ON_THAT_FILTER" : "VALUE_YOU_WANT_TO_PASS",
      "userStatus" : "online",
      "minSubscriptors" : "1"
    }
  },
  "index" : {
    "index" : "tracker",
    "type" : "user",
    "bulk_size" : "100",
    "bulk_timeout" : "10ms"
  }
}

尽管过滤器只能过滤整个文档,following CouchDB 1.2 it is possible to provide a view as filter .

除了使用过滤器外,Elasticsearch 还有一个 script 钩子(Hook)来预处理输入数据。 It is possible to mutate document in this hook and Elasticsearch stores the mutated version .

{
  "type" : "couchdb",
  "couchdb" : {
    "script" : "ctx.doc.password = undefined"
  },
  "index" : {
  }
}

关于couchdb - 通过 CouchDB-River 将字段排除在 Elasticsearch 索引之外,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18983992/

相关文章:

elasticsearch - Elasticsearch是否仅对_search端点或全部支持GET over POST?

elasticsearch - 空值会为Elasticsearch完成建议者字段生成mapper_parsing_exception

maven - Web应用程序中的Elasticsearch Java API错误:java.lang.NoClassDefFoundError:无法初始化类org.elasticsearch.threadpool.ThreadPool

json - CouchDB 中奇怪的 JSON

android - CouchDB 复制到 Android ...适用于 Android 应用程序、Android 浏览器还是?

security - CouchDB over HTTPS 和自认证证书 : browsers reject it

mapreduce - 如何编写 CouchDb View ?

couchdb - 如何在 CouchDB VIEW 中搜索包含 '&' 或 '"' 的键

elasticsearch - sebp/elk logstash无法使用Kafka接收数据

elasticsearch - 删除快照时,不会删除我的ElasticSearch快照索引目录