Last active
August 29, 2015 14:03
-
-
Save Haraldson/fed20ebee0bdb7ee651b to your computer and use it in GitHub Desktop.
Cloudant indexing
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') | |
{ | |
var indexProperties = function(properties) | |
{ | |
for(var i = 0; i < properties.length; i++) | |
{ | |
var property = properties[i]; | |
if(doc[property]) | |
index(property, doc[property], { store: 'yes' }); | |
} | |
}; | |
var indexPropertiesWithFallbackValue = function(properties) | |
{ | |
for(var property in properties) | |
{ | |
var value = property in doc ? doc[property] : properties[property]; | |
index(property, value, { store: 'yes' }); | |
} | |
}; | |
index('default', doc.title); | |
indexProperties( | |
[ | |
'title', | |
'publicationId', | |
'liveStartDate', | |
'liveEndDate', | |
'created', | |
'type', | |
'docType' | |
]); | |
indexPropertiesWithFallbackValue( | |
{ | |
published: true, | |
scheduled: false | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment