{"action":"created","issue":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5793","repository_url":"https://api.github.com/repos/rethinkdb/rethinkdb","labels_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5793/labels{/name}","comments_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5793/comments","events_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5793/events","html_url":"https://github.com/rethinkdb/rethinkdb/issues/5793","id":156564847,"number":5793,"title":"Issue with nested query and lack of good documentation ","user":{"login":"carlskii","id":555399,"avatar_url":"https://avatars.githubusercontent.com/u/555399?v=3","gravatar_id":"","url":"https://api.github.com/users/carlskii","html_url":"https://github.com/carlskii","followers_url":"https://api.github.com/users/carlskii/followers","following_url":"https://api.github.com/users/carlskii/following{/other_user}","gists_url":"https://api.github.com/users/carlskii/gists{/gist_id}","starred_url":"https://api.github.com/users/carlskii/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/carlskii/subscriptions","organizations_url":"https://api.github.com/users/carlskii/orgs","repos_url":"https://api.github.com/users/carlskii/repos","events_url":"https://api.github.com/users/carlskii/events{/privacy}","received_events_url":"https://api.github.com/users/carlskii/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":5,"created_at":"2016-05-24T17:30:19Z","updated_at":"2016-05-24T20:53:42Z","closed_at":null,"body":"Hi,\r\n\r\nI'm struggling to get my head around a nested query. \r\n\r\nI have several docs that look like this: \r\n\r\n```json\r\n{\r\n\t\"blobs\": [{\r\n\t\t\"base64\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\"data\": {\r\n\t\t\t\"Info:\": {\r\n\t\t\t\t\"length\": 1024\r\n\t\t\t},\r\n\t\t\t\"Serial Number\": 123456,\r\n\t\t\t\"Validity\": {\r\n\t\t\t\t\"begin\": \"20280801235959Z\",\r\n\t\t\t\t\"end\": \"19960129000000Z\"\r\n\t\t\t},\r\n\t\t\t\"Version\": 0,\r\n\t\t\t\"hash\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\t\"item count:\": 0,\r\n\t\t\t\"meta1\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t},\r\n\t\t\t\"meta2\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t}\r\n\t\t},\r\n\t\t\"fingerprint\": \"123\"\r\n\t}, {\r\n\t\t\"base64\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\"data\": {\r\n\t\t\t\"Info:\": {\r\n\t\t\t\t\"length\": 1024\r\n\t\t\t},\r\n\t\t\t\"Serial Number\": 123456,\r\n\t\t\t\"Validity\": {\r\n\t\t\t\t\"begin\": \"20280801235959Z\",\r\n\t\t\t\t\"end\": \"19960129000000Z\"\r\n\t\t\t},\r\n\t\t\t\"Version\": 0,\r\n\t\t\t\"hash\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\t\"item count:\": 0,\r\n\t\t\t\"meta1\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t},\r\n\t\t\t\"meta2\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t}\r\n\t\t},\r\n\t\t\"fingerprint\": \"456\"\r\n\t}, {\r\n\t\t\"base64\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\"data\": {\r\n\t\t\t\"Info:\": {\r\n\t\t\t\t\"length\": 1024\r\n\t\t\t},\r\n\t\t\t\"Serial Number\": 123456,\r\n\t\t\t\"Validity\": {\r\n\t\t\t\t\"begin\": \"20280801235959Z\",\r\n\t\t\t\t\"end\": \"19960129000000Z\"\r\n\t\t\t},\r\n\t\t\t\"Version\": 0,\r\n\t\t\t\"hash\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\t\"item count:\": 0,\r\n\t\t\t\"meta1\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t},\r\n\t\t\t\"meta2\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t}\r\n\t\t},\r\n\t\t\"fingerprint\": \"789\"\r\n\t}, {\r\n\t\t\"base64\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\"data\": {\r\n\t\t\t\"Info:\": {\r\n\t\t\t\t\"length\": 1024\r\n\t\t\t},\r\n\t\t\t\"Serial Number\": 123456,\r\n\t\t\t\"Validity\": {\r\n\t\t\t\t\"begin\": \"20280801235959Z\",\r\n\t\t\t\t\"end\": \"19960129000000Z\"\r\n\t\t\t},\r\n\t\t\t\"Version\": 0,\r\n\t\t\t\"hash\": \"MIICPDCCAaUCEHC65B0Q2Sk0tjjKe\",\r\n\t\t\t\"item count:\": 0,\r\n\t\t\t\"meta1\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t},\r\n\t\t\t\"meta2\": {\r\n\t\t\t\t\"a\": \"abc\",\r\n\t\t\t\t\"b\": \"bcd\",\r\n\t\t\t\t\"c\": \"cdf\"\r\n\t\t\t}\r\n\t\t},\r\n\t\t\"fingerprint\": \"101112\"\r\n\t}],\r\n\t\"complete\": false,\r\n\t\"fast\": true,\r\n\t\"id\": \"33beabc8-9d5b-44f8-bc3b-d346387b1bc9\",\r\n\t\"items\": [{\r\n\t\t\"blobs\": [\r\n\t\t\t\"123\",\r\n\t\t\t\"457\",\r\n\t\t\t\"789\",\r\n\t\t\t\"10112\"\r\n\t\t]\r\n\t}],\r\n\t\"port\": 443,\r\n\t\"secure\": true\r\n}\r\n```\r\n\r\nI can easily query and match on `fingerprint` which then returns the documents that match. \r\n\r\n```javascript\r\nr.db('db').table(\"test2\").concatMap(function(doc) {\r\n    return doc(\"blobs\")\r\n}).filter(function(carl) {\r\n  return carl(\"fingerprint\").match(\"123\")\r\n})\r\n```\r\nHowever, I need to match on more than one field and according to the docs I can do this.\r\n\r\n```javascript\r\nr.db('db').table(\"test2\").concatMap(function(doc) {\r\n    return doc(\"blobs\")\r\n}).filter(function(carl) {\r\n  return carl(\"fingerprint\").match(\"123\").and([\"meta1\"][\"b\"]).match(\"bcd\")\r\n})\r\n```\r\nHowever, I get an error. \r\n\r\n```\r\ne: Argument 1 to and may not be `undefined`.\r\n```\r\n\r\n\r\nUnfrotuantly, the docs seem a little light on good working examples for this sort of thing. Are rich examples anywhere ?  "},"comment":{"url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/comments/221397916","html_url":"https://github.com/rethinkdb/rethinkdb/issues/5793#issuecomment-221397916","issue_url":"https://api.github.com/repos/rethinkdb/rethinkdb/issues/5793","id":221397916,"user":{"login":"deontologician","id":1366,"avatar_url":"https://avatars.githubusercontent.com/u/1366?v=3","gravatar_id":"","url":"https://api.github.com/users/deontologician","html_url":"https://github.com/deontologician","followers_url":"https://api.github.com/users/deontologician/followers","following_url":"https://api.github.com/users/deontologician/following{/other_user}","gists_url":"https://api.github.com/users/deontologician/gists{/gist_id}","starred_url":"https://api.github.com/users/deontologician/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deontologician/subscriptions","organizations_url":"https://api.github.com/users/deontologician/orgs","repos_url":"https://api.github.com/users/deontologician/repos","events_url":"https://api.github.com/users/deontologician/events{/privacy}","received_events_url":"https://api.github.com/users/deontologician/received_events","type":"User","site_admin":false},"created_at":"2016-05-24T20:53:42Z","updated_at":"2016-05-24T20:53:42Z","body":"In the python driver, you'd use `[]` brackets. Also I realized I misread your data structure. You will need to use concatmap to join up all of the arrays in 'blob':\r\n\r\n```py\r\nr.db('db').table('test2').concat_map(lambda b: b['blobs']).filter({'fingerprint': '123', 'metal': {'b': 'bcd'}})\r\n```"}}
{"actor":{"display_login":"deontologician"}}