Created
January 1, 2016 00:27
-
-
Save grant/67c913b41934a32af5e6 to your computer and use it in GitHub Desktop.
Search ranking for AlgoDB
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
/** | |
* Searches the elastic search db. | |
* @param {String} query The raw text query | |
* @param {Callback} cb The response callback | |
* @return {Object} hits The hits from elasticsearch | |
*/ | |
var search = function(query, cb) { | |
var url = ELASTIC_SEARCH_URL + 'algorithm/_search'; | |
var body = { | |
query: { | |
multi_match: { | |
query: query, | |
fields: ['name^3', 'tag_line^1.5', 'description'], | |
fuzziness: 'AUTO' | |
} | |
}, | |
min_score: 0.5, | |
size: MAX_RESULTS_PER_PAGE, | |
}; | |
request({ | |
url: url, | |
body: body, | |
json: true | |
}, function(error, response, body) { | |
// Gather algorithm information from their ids | |
// And send the search result data to the HTML template engine... | |
}); | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment