2016-04-25 72 views
0

没有可用的指标,我想检索文档_idvalue === 13anotherValue === 56

  • 1

    OR

  • 文件

错误:

There is no index available for this selector.

这是我的查询:

{ 
    "selector": { 
     "$or": [ 
      { 
       "_id": "1" 
      }, 
      { 
       "value": "13", 
       "anotherValue": "56" 
      } 
     ] 
    } 
} 

指标设置:

Your available Indexes: 
special: _id 
json: value, anotherValue 
json: _id, value, anotherValue 

回答

3

对于这个查询,你需要添加一个选择让所有的ID,像这样:

{ 
    "selector": { 
     "_id": {"$gt":null}, 
     "$or": [ 
      { 
       "_id": "1" 
      }, 
      { 
       "value": "13", 
       "anotherValue": "56" 
      } 
     ] 
    } 
} 

你可以学习m矿石在这里:

https://cloudant.com/blog/mango-json-vs-text-indexes/

而这SO帖子:

index and query items in an array with mango query for cloudant and couchdb 2.0

或者,您也可以在所有字段添加一个文本索引:

{ 
    "index": {}, 
    "type": "text" 
} 

然后你原来的选择应该管用。

+0

谢谢!任何机会你可以看看这个(类似,但使用'sort'):http://stackoverflow.com/questions/36868228/perform-sort-on-field-thats-not-primary-index – bobbyrne01