Created
June 26, 2014 15:14
-
-
Save Haraldson/222cfb62f70aa0b25ef4 to your computer and use it in GitHub Desktop.
Cloudant indexing the WET way
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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