[Couchdb Wiki] Update of "View_collation" by JoanTouzet

2018-04-12 Thread Apache Wiki
Dear wiki user,

You have subscribed to a wiki page "Couchdb Wiki" for change notification.

The page "View_collation" has been deleted by JoanTouzet:

https://wiki.apache.org/couchdb/View_collation?action=diff&rev1=22&rev2=23

- <>
  
- '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/stable/ddocs/views/collation.html.
- 


[Couchdb Wiki] Update of "View_collation" by JoanTouzet

2018-04-06 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for 
change notification.

The "View_collation" page has been changed by JoanTouzet:
https://wiki.apache.org/couchdb/View_collation?action=diff&rev1=20&rev2=21

  <>
  
- = View Collation =
- '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/latest/couchapp/views/collation.html.
+ '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/2.1.1/ddocs/views/collation.html.
  


[Couchdb Wiki] Update of "View_collation" by JoanTouzet

2018-04-06 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for 
change notification.

The "View_collation" page has been changed by JoanTouzet:
https://wiki.apache.org/couchdb/View_collation?action=diff&rev1=21&rev2=22

  <>
  
- '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/2.1.1/ddocs/views/collation.html.
+ '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/stable/ddocs/views/collation.html.
  


[Couchdb Wiki] Update of "View_collation" by JoanTouzet

2018-04-06 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for 
change notification.

The "View_collation" page has been changed by JoanTouzet:
https://wiki.apache.org/couchdb/View_collation?action=diff&rev1=19&rev2=20

Comment:
Removing content in preparation for decom

  = View Collation =
  '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/latest/couchapp/views/collation.html.
  
- <>
- 
- A simple introduction to CouchDB view collation.
- 
- == Basics ==
- View functions specify a key and a value to be returned for each row. CouchDB 
collates the view rows by this key. In the following example, the !LastName 
property serves as the key, thus the result will be sorted by !LastName:
- 
- {{{
- function(doc) {
-   if (doc.Type == "customer") {
- emit(doc.LastName, {FirstName: doc.FirstName, Address: doc.Address});
-   }
- }
- }}}
- CouchDB allows arbitrary JSON structures to be used as keys. You can use 
complex keys for fine-grained control over sorting and grouping.
- 
- == Examples ==
- The following clever trick would return both customer and order documents. 
The key is composed of a customer ''_id'' and a sorting token. Because the key 
for order documents begins with the ''_id'' of a customer document, all the 
orders will be sorted by customer. Because the sorting token for customers is 
lower than the token for orders, the customer document will come before the 
associated orders. The values ''0'' and ''1'' for the sorting token are 
arbitrary.
- 
- {{{
- function(doc) {
-   if (doc.Type == "customer") {
- emit([doc._id, 0], doc);
-   } else if (doc.Type == "order") {
- emit([doc.customer_id, 1], doc);
-   }
- }
- }}}
- This trick was 
[[http://www.cmlenz.net/blog/2007/10/couchdb-joins.html|originally documented]] 
by Christopher Lenz. See also 
[[http://stackoverflow.com/questions/6064987/couchdb-map-reduce-how-to-output-less-rows/6066433#6066433|jhs
 answer on stackoverflow]] for more useful tips.
- 
- === Sorting by Dates ===
- It maybe be convenient to store date attributes in a human readable format 
(i.e. as a String), but still sort by date. This can be done by converting the 
date to a number in the emit function. For example, given a document with a 
created_at attribute of 'Wed Jul 23 16:29:21 +0100 2008', the following emit 
function would sort by date
- 
- {{{
- emit(Date.parse(doc.created_at).getTime(), doc);
- }}}
- Alternatively, if you use a date format which sorts lexicographically, such 
as "2008/06/09 13:52:11 +" you can just
- 
- {{{
- emit(doc.created_at, doc);
- }}}
- and avoid the conversion. As a bonus, this date format is compatible with the 
Javascript date parser, so you can use ''new Date(doc.created_at)'' in your 
client side Javascript to make date sorting easy in the browser.
- 
- === String Ranges ===
- If you need start and end keys that encompass every string with a given 
prefix, it is better to use a high value unicode character, than to use a 
'' suffix.
- 
- That is, rather than:
- 
- {{{
- startkey="abc"&endkey="abcZ"
- }}}
- You should use:
- 
- {{{
- startkey="abc"&endkey="abc\ufff0"
- }}}
- == Collation Specification ==
- This section is based on the ''view_collation'' function in 
''couch_tests.js'':
- 
- {{{
- // special values sort before all other types
- null
- false
- true
- 
- // then numbers
- 1
- 2
- 3.0
- 4
- 
- // then text, case sensitive
- "a"
- "A"
- "aa"
- "b"
- "B"
- "ba"
- "bb"
- 
- // then arrays. compared element by element until different.
- // Longer arrays sort after their prefixes
- ["a"]
- ["b"]
- ["b","c"]
- ["b","c", "a"]
- ["b","d"]
- ["b","d", "e"]
- 
- // then object, compares each key value in the list until different.
- // larger objects sort after their subset objects.
- {a:1}
- {a:2}
- {b:1}
- {b:2}
- {b:2, a:1} // Member order does matter for collation.
-// CouchDB preserves member order
-// but doesn't require that clients will.
-// this test might fail if used with a js engine
-// that doesn't preserve order
- {b:2, c:2}
- }}}
- Comparison of strings is done using [[http://site.icu-project.org/|ICU]] 
which implements the [[http://www.unicode.org/unicode/reports/tr10/|Unicode 
Collation Algorithm]], giving a dictionary sorting of keys. This can give 
surprising results if you were expecting ASCII ordering. Note that:
- 
-  * All symbols sort before numbers and letters (even the "high" symbols like 
tilde, 0x7e)
-  * Differing sequences of letters are compared without regard to case, so a < 
aa but also A < aa and a < AA
-  * Identical sequences of letters are compared with regard to case, with 
lowercase ''before'' uppercase, so a < A
- 
- You can demonstrate the collation sequence for 7-bit ASCII characters like 
this:
- 
- {{{
- require 'rubygems'
- require 'restclient'
- require 'json'
- 
- DB="http://127.0.0.1:5984/collator";
- 
- RestClient.delete DB rescue nil
-

[Couchdb Wiki] Update of "View_collation" by JoanTouzet

2014-03-24 Thread Apache Wiki
Dear Wiki user,

You have subscribed to a wiki page or wiki category on "Couchdb Wiki" for 
change notification.

The "View_collation" page has been changed by JoanTouzet:
https://wiki.apache.org/couchdb/View_collation?action=diff&rev1=18&rev2=19

  <>
  
  = View Collation =
+ '''This page has been replaced by the official documentation''' '''at''' 
http://docs.couchdb.org/en/latest/couchapp/views/collation.html.
- 
- See also the 
[[http://docs.couchdb.org/en/latest/couchapp/views/collation.html]] for this 
topic.
  
  <>
  
@@ -34, +33 @@

}
  }
  }}}
+ This trick was 
[[http://www.cmlenz.net/blog/2007/10/couchdb-joins.html|originally documented]] 
by Christopher Lenz. See also 
[[http://stackoverflow.com/questions/6064987/couchdb-map-reduce-how-to-output-less-rows/6066433#6066433|jhs
 answer on stackoverflow]] for more useful tips.
- This trick was 
[[http://www.cmlenz.net/blog/2007/10/couchdb-joins.html|originally documented]] 
by Christopher Lenz.
- See also 
[[http://stackoverflow.com/questions/6064987/couchdb-map-reduce-how-to-output-less-rows/6066433#6066433|jhs
 answer on stackoverflow]] for more useful tips.
  
  === Sorting by Dates ===
  It maybe be convenient to store date attributes in a human readable format 
(i.e. as a String), but still sort by date. This can be done by converting the 
date to a number in the emit function. For example, given a document with a 
created_at attribute of 'Wed Jul 23 16:29:21 +0100 2008', the following emit 
function would sort by date