Do i need to escape keys when loading from a view?

i have a view emiting what looks like this

Key | Value
---------------------
one | something
two | something
a.b | something

now when querying, i can't get the a.b to show up, i'm assuming its the period in the middle. what do i have to do to get it to work? the other 2 show up fine.

ie:

$keys = ["one","two","a.b"];
$this->Couch()->view("dev_domain", "FullNameView",array("keys"=>array_keys($keys)));

only returns one and two.

Also not in love with having to use array_keys, but that's another issue.

Thanks

3 Answers

« Back to question.

I have the same problem searching for keys that contain special character.
I updated my .Net Client to 1.3.3 and make sure Im using the correct version of Newtonsoft.

{
"name": "Abercrombie & Fitch Company",
"isactive": true,
"sysdate": "2014-02-09T19:32:48",
"type": "company"
}
{
"name": "Jason's Store",
"isactive": true,
"sysdate": "2014-02-09T19:32:48",
"type": "company"
}
{
"name": "A.H. Belo Corporation",
"isactive": true,
"sysdate": "2014-02-09T19:32:48",
"type": "company"
}

function (doc, meta) {
if (doc.type == "company" && doc.name) {
emit(doc.name, null);
}
}

protected IView GetView(string name, string startKey, string endKey, int limit, bool isProjection = false)
{
string test = "Abercrombie & Fitch Company";
return _Client.GetView(_designDoc, name, isProjection).StartKey(test).EndKey(endKey).Limit(limit);
}

Error:
Cannot deserialize the current JSON array (e.g. [1,2,3]) into type....
because the type requires a JSON object (e.g. {\"name\":\"value\"}) to deserialize correctly.
Newtonsoft.Json.JsonException {Newtonsoft.Json.JsonSerializationException}

« Back to question.

Hello,

Doing the following works for me:

$keys = array("one","a.b");
$results = $cb->view("test", "by_id",  array('keys' => $keys) );

Note: I am not a PHP specialist just doing basic tests. Is it ok for your application?

Regards
Tug
@tgrall

« Back to question.

Its better to fix your output by making a better map function. Remember the mapper is javascript so you can use basic function to check and/or cleanup what you emit.

if you put up some of your data and your current map function I might be able to help you.