Skip to content

Instantly share code, notes, and snippets.

@harishvc
Last active August 29, 2015 14:15
Show Gist options
  • Save harishvc/9403c1ad2bb45fbdf0c1 to your computer and use it in GitHub Desktop.
Save harishvc/9403c1ad2bb45fbdf0c1 to your computer and use it in GitHub Desktop.
Ask GitHub
###Output Log###
2015-02-15 07:33:01 start processing ... http://data.githubarchive.org/2015-02-15-13.json.gz
## entries generated from githubarchive.org: 14,983
2015-02-15 07:33:07 end processing
2015-02-15 07:33:07 start inserting to mongodb
Deleting entries older than 1423928036142
## deleted: 16,182
start re-index
### documents: 310,514
2015-02-15 07:34:10 end inserting to mongodb
### 2015-02-15 07:34:12 MongoDB Stats ###
Documents: 310,514
Size: 187.1 MB
#Search aggregation pipeline using text index score
#Location: /DBQueries.py
pipeline = [
{ '$match': { '$text': { '$search': query }, 'type':'PushEvent' }},
{ '$group': {'_id': {'full_name': "$full_name",'score': { '$meta': "textScore" }} ..}}
..
{ '$sort': { 'score': -1, 'count': -1}}
]
//Location: /static/js/typeahead.js
var TQuestions = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.tokens.join(' ')); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
prefetch: '/static/typeahead/queries.json'
});
var RQuestions = new Bloodhound({
datumTokenizer: function(d) { return Bloodhound.tokenizers.whitespace(d.tokens.join(' ')); },
queryTokenizer: Bloodhound.tokenizers.whitespace,
limit: 10,
remote: '/tsearch?q=%QUERY'
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment