2015-06-15 2 views
0

Мои данные следующим образом:непрерывно получать нулевые значения для снижения функции

{ 

    "_id": "33d4d945613344f13a3ee929337b1ca8", 
    "_rev": "1-427c691a5c5f504c6b1d885b6b9ff4bc", 
    "release": { 
     "genres": { 
      "genre": "Electronic" 
     }, 
     "identifiers": { 
      "identifier": [ 
       { 
        "description": "Text", 
        "value": "5 021603 054028", 
        "type": "Barcode" 
       }, 
       { 
        "description": "String", 
        "value": 5021603054028, 
        "type": "Barcode" 
       }, 
       { 
        "value": "MAYKING WAP54CD", 
        "type": "Matrix/Runout" 
       } 
      ] 
     }, 
     "status": "Accepted", 
     "videos": { 
      "video": [ 
       { 
        "title": "Autechre - Lost", 
        "duration": 471, 
        "description": "Autechre - Lost", 
        "src": "http://www.youtube.com/watch?v=R7EoDcb9738", 
        "embed": true 
       }, 
       { 
        "title": "djarum - autechre.flv", 
        "duration": 434, 
        "description": "djarum - autechre.flv", 
        "src": "http://www.youtube.com/watch?v=gaRTvCUcBJo", 
        "embed": true 
       }, 
       { 
        "title": "Flutter [33 ⅓ Speed]", 
        "duration": 807, 
        "description": "Flutter [33 ⅓ Speed]", 
        "src": "http://www.youtube.com/watch?v=JX3sLwcEWmM", 
        "embed": true 
       }, 
       { 
        "title": "Autechre - Flutter", 
        "duration": 598, 
        "description": "Autechre - Flutter", 
        "src": "http://www.youtube.com/watch?v=EZFmZ0gZNZI", 
        "embed": true 
       } 
      ] 
     }, 
     "labels": { 
      "label": { 
       "catno": "WAP54CD", 
       "name": "Warp Records" 
      } 
     }, 
     "companies": { 
      "company": [ 
       { 
        "id": 264514, 
        "catno": "", 
        "name": "Warp Records Limited", 
        "entity_type_name": "Phonographic Copyright (p)", 
        "resource_url": "http://api.discogs.com/labels/264514", 
        "entity_type": 13 
       }, 
       { 
        "id": 264514, 
        "catno": "", 
        "name": "Warp Records Limited", 
        "entity_type_name": "Copyright (c)", 
        "resource_url": "http://api.discogs.com/labels/264514", 
        "entity_type": 14 
       }, 
       { 
        "id": 265170, 
        "catno": "", 
        "name": "Warp Music", 
        "entity_type_name": "Published By", 
        "resource_url": "http://api.discogs.com/labels/265170", 
        "entity_type": 21 
       }, 
       { 
        "id": 45746, 
        "catno": "", 
        "name": "EMI Music", 
        "entity_type_name": "Published By", 
        "resource_url": "http://api.discogs.com/labels/45746", 
        "entity_type": 21 
       }, 
       { 
        "id": 147881, 
        "catno": "", 
        "name": "Mayking", 
        "entity_type_name": "Pressed By", 
        "resource_url": "http://api.discogs.com/labels/147881", 
        "entity_type": 17 
       } 
      ] 
     }, 
     "styles": { 
      "style": "IDM" 
     }, 
     "formats": { 
      "format": { 
       "text": "", 
       "name": "CD", 
       "qty": 1, 
       "descriptions": { 
        "description": "EP" 
       } 
      } 
     }, 
     "country": "UK", 
     "id": 158, 
     "released": "1994-09-03", 
     "artists": { 
      "artist": { 
       "id": 41, 
       "anv": "", 
       "name": "Aphex Twin", 
       "role": "", 
       "tracks": "", 
       "join": "" 
      } 
     }, 
     "title": "Anti EP", 
     "master_id": 1315, 
     "tracklist": { 
      "track": [ 
       { 
        "position": 1, 
        "duration": "7:24", 
        "title": "Lost" 
       }, 
       { 
        "position": 2, 
        "duration": "7:19", 
        "title": "Djarum" 
       }, 
       { 
        "position": 3, 
        "duration": "9:57", 
        "title": "Flutter" 
       } 
      ] 
     }, 
     "data_quality": "Correct", 
     "extraartists": { 
      "artist": [ 
       { 
        "id": 445854, 
        "anv": "", 
        "name": "Designers Republic, The", 
        "role": "Design", 
        "tracks": "", 
        "join": "" 
       }, 
       { 
        "id": 41, 
        "anv": "", 
        "name": "Aphex Twin", 
        "role": "Producer", 
        "tracks": "", 
        "join": "" 
       }, 
       { 
        "id": 300407, 
        "anv": "Brown", 
        "name": "Rob Brown (3)", 
        "role": "Written-By", 
        "tracks": "", 
        "join": "" 
       }, 
       { 
        "id": 42, 
        "anv": "Booth", 
        "name": "Sean Booth", 
        "role": "Written-By", 
        "tracks": "", 
        "join": "" 
       } 
      ] 
       } 
} 

Я попытался получить значения для художника Aphex Twin

Я картировать, используя следующий код:

function(doc){ 
if(doc.release) 
emit(doc.release.artists.artist.name,doc.release.title) 
} 

Картирование завершено успешно, и я попытался отфильтровать все те значения, которые содержали имя исполнителя «Aphex Twin». Я использовал следующую команду:

function(keys, vals, rereduce) { 

for(var i = 0; i < keys.length; i++) 
{if(keys[i][0]=="Aphex Twin") 
return values[i] 
} 
} 

я получить ответ как

response

P.S. Если я использую ключи завиток, то я получаю ошибку

curl -X GET http://localhost:5984/smalldiscogs/_design/myvie 
ws/_view/Aphextwin?group=false&keys="Aphex Twin" 

После того, как все отображенные результаты, я получаю сообщение об ошибке

An incorrect parameter was 
    entered for the command. 

ответ

0

функция Карта:

function(doc){ 
if(doc.release) 
emit([doc.release.artists.artist.name,doc.release.title],1) 
} 

После сохранения, получить информацию с помощью URL

Result

Смежные вопросы