Last active
December 26, 2015 19:49
-
-
Save erberg-snippets/7203768 to your computer and use it in GitHub Desktop.
This file contains 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
/** | |
* Build a SOLR query using kay-value pairs from queryObject. | |
* @param {Object} queryObject Object conaining the name and value for each search parameter. | |
* @return {String} Query string to be appended to URL | |
*/ | |
function buildSOLRQuery(queryObject) { | |
var queryString = ''; | |
for (key in queryObject) { | |
if (queryObject[key] !== '') { | |
queryString += (queryString ? ' AND ' : '') + //If queryString is not empty, add '&' at the beginning | |
key + ':' + queryObject[key]; | |
} | |
} | |
return queryString; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment