如何索引多个字段以允许在不提供字段名称的情况下查询所有字段?

how can I index more than one field to allow querying them all without providing the field name?

我想在使用 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});
  }
}

文档还提供了以下描述:

If the special value "default" is used when defining the name, you do not have to specify a field name at query time.

我可以定义一个 "default" 索引吗?例如

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

是的,您可以根据需要定义任意多个 "default" 索引。看来即使混合类型也应该可以查询。