【问题标题】:how can I index more than one field to allow querying them all without providing the field name?如何索引多个字段以允许在不提供字段名称的情况下查询所有字段?
【发布时间】:2016-11-16 21:13:05
【问题描述】:

我想在使用 Cloudant 搜索索引时搜索文档中的所有字段,而不必指定字段名称。

cloudant docs 提供了 doc._id 上默认字段索引的示例:

function(doc){
  index("default", doc._id);
  if (doc.min_length){
    index("min_length", doc.min_length, {"store": true});
  }
  if (doc.diet){
    index("diet", doc.diet, {"store": true});
  }
  if (doc.latin_name){
    index("latin_name", doc.latin_name, {"store": true});
  }
  if (doc.class){
    index("class", doc.class, {"store": true});
  }
}

文档也提供了这样的描述:

如果在定义名称时使用特殊值“default”,则不必在查询时指定字段名称。

我可以定义多个“默认”索引吗?例如

function(doc){
  index("default", doc._id);
  index("default", doc.min_length, {"store": true});
  ... 
}

【问题讨论】:

    标签: lucene cloudant


    【解决方案1】:

    是的,您可以根据需要定义任意数量的“默认”索引。似乎即使混合类型也适合查询。

    【讨论】:

      猜你喜欢
      • 2015-07-12
      • 2010-11-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多