2016-04-25 9 views
0

Ich mag würde

  • Dokument mit _id von 1

    ODER

  • Dokument mit value === 13 UND anotherValue === 56 abrufen

Fehler:

There is no index available for this selector.

Diese meine Frage ist:

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

Indizes Setup:

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

Antwort

3

Für diese Abfrage Sie einen Selektor hinzufügen müssen, wie so alle IDs zu erhalten:

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

Sie können m lernen Erz hier:

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

Und dieses SO Beitrag:

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

Alternativ können Sie einen Textindex für alle Felder hinzufügen:

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

Und dann Ihre ursprüngliche Selektor sollte arbeiten.

+0

danke! Jede Chance, die Sie sich ansehen könnten (ähnlich, aber mit 'sort'): http://stackoverflow.com/questions/36868228/perform-sort-on-field-thats-not-primary-index – bobbyrne01