Commit bd22428
committed
[WIP] Selector-based simple views
Try to see what a simple selector-based views might look like. Inspired by
comments in the "allow_fallback" pr and the discussion in CouchDB dev
meeting.
This is as simple as possible:
* We already have support for design doc languages, so go with
that: use "selector" as a language, then use the regular `_design/../_view` API
* `selector` picks documents to be indexed. The usual selector syntax, nothing new
* `keys` - list of field values emitted as the key (an array)
* `values` - list of fields values emitted as the value (an array)
Example (DB=http://adm:[email protected]:15984)
```
echo "Recreating DB"
http -q delete $DB/db1
http -b put $DB/db1
echo "Adding some docs"
http -b put $DB/db1/a k:='1' v=x s:='10'
http -b put $DB/db1/b k:='3' v=x s:='11'
http -b put $DB/db1/c k:='4' v=y s:='12'
http -b put $DB/db1/d k:='2' v=x s:='13'
http -b put $DB/db1/e k:='5' v=x s:='14'
http -b put $DB/db1/f w:='1' v=x s:='15'
http -b put $DB/db1/g k:='3' o=o s:='16'
echo "Add two silly selector thingers"
http -b put $DB/db1/_design/s language=selector views:='{
"v1": {"map": {"selector": {"s":{"$gt":12}}, "keys":["k"], "values":["v"]}},
"v2": {"map": {"keys":["w"]}}
}'
echo "Query the silly selector thinger"
http -b $DB/db1/_design/s/_view/v1
echo "Query the even sillier one without a selector"
http -b $DB/db1/_design/s/_view/v2
```
Query the silly selector thinger
```
{
"offset": 0,
"rows": [
{"id": "d", "key": [2], "value": ["x"]},
{"id": "e", "key": [5], "value": ["x"]}
],
"total_rows": 2
}
```
Query the even sillier one without a selector. Pick docs based on `keys` only.
```
{
"offset": 0,
"rows": [
{"id": "f", "key": [1], "value": null}
],
"total_rows": 1
}
```1 parent 1f3396c commit bd22428
File tree
3 files changed
+166
-0
lines changed- src
- couch_mrview/src
- couch/src
- mango/src
3 files changed
+166
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
142 | 142 | | |
143 | 143 | | |
144 | 144 | | |
| 145 | + | |
145 | 146 | | |
146 | 147 | | |
147 | 148 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
177 | 177 | | |
178 | 178 | | |
179 | 179 | | |
| 180 | + | |
180 | 181 | | |
181 | 182 | | |
182 | 183 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
0 commit comments