Querying views with multiple parameters leaving some blank

Hi
I’m trying to query the following view:

function (doc, meta) {
if(doc.theCollection==“personal_record”) {
emit([doc.userId,doc.torusId,doc.score,doc.nMoves,doc.packId,doc.userName], null);
}
}

I’d query based on range and fixing only the first two parameters like this:
startKey = [“myuserId”,“myTorusId”,0,0,“”,“”] endKey =[“myuserId”,“myTorusId”,999,999,“~”,“~”]
but the view returns nothing, when I know at least a document starting with these keys exists
what am I missing in passing start and end keys?

Hi @mikbin80,

I created a single document:

{
  "nMoves": 0,
  "packId": "",
  "score": 0,
  "torusId": "myTorusId",
  "userId": "myuserId",
  "userName": ""
}

Then I added some filtering:

mr%20filter

(url: http://127.0.0.1:8092/forumsMR/_design/dev_forums/_view/forumstest?limit=6&stale=false&connection_timeout=60000&inclusive_end=true&skip=0&full_set=true&startkey=["myuserId"%2C"myTorusId"%2C0%2C0%2C""%2C""]&endkey=["myuserId"%2C"myTorusId"%2C999%2C999%2C"~"%2C"~"])

I got a result:

mr%20result

Am I doing something different than you?

Hi Matthew,
thanks for your help.
I think I’m misunderstaing some sorting with strings in javascript.
I’ve tested a view with 4 parameters and it works, so I think I’m just messing up thinks with that collection.
thanks again

1 Like