Skip to content

Instantly share code, notes, and snippets.

@grant
Created January 1, 2016 00:27
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save grant/67c913b41934a32af5e6 to your computer and use it in GitHub Desktop.
Save grant/67c913b41934a32af5e6 to your computer and use it in GitHub Desktop.
Search ranking for AlgoDB
/**
* 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