Skip to content

Instantly share code, notes, and snippets.

@Haraldson
Created June 26, 2014 15:14
Show Gist options
  • Save Haraldson/222cfb62f70aa0b25ef4 to your computer and use it in GitHub Desktop.
Save Haraldson/222cfb62f70aa0b25ef4 to your computer and use it in GitHub Desktop.
Cloudant indexing the WET way
function (doc) {
if (doc.docType === 'issue') {
index('default', doc.title);
if (doc.title) {
index('title', doc.title, {'store': 'yes'});
}
if (doc.publicationId) {
index('publicationId', doc.publicationId, {'store': 'yes'});
}
if (doc.liveStartDate) {
index('liveStartDate', Date.parse(doc.liveStartDate), {'store': 'yes'});
}
if (doc.created) {
index('created', Date.parse(doc.created), {'store': 'yes'});
}
if (doc.liveEndDate) {
index('liveEndDate', doc.liveEndDate, {'store': 'yes'});
}
if (doc.type) {
index('type', doc.type, {'store': 'yes'});
}
if (doc.docType){
index('docType', doc.docType, {'store': 'yes'});
}
if (doc.priority){
index('priority', doc.priority, {'store' : 'yes'});
}
if ('published' in doc){
index('published', doc.published, {'store' : 'yes'});
} else {
index('published', true, {'store' : 'yes'});
}
if ('scheduled' in doc){
index('scheduled', doc.scheduled, {'store' : 'yes'});
} else {
index('scheduled', false, {'store' : 'yes'});
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment