Skip to content

Instantly share code, notes, and snippets.

@vfulco
Forked from cpatrick/runsearch.py
Created November 26, 2015 08:11
Show Gist options
  • Save vfulco/6ee6aa254f863ab09e2d to your computer and use it in GitHub Desktop.
Save vfulco/6ee6aa254f863ab09e2d to your computer and use it in GitHub Desktop.
Sample Python for running a full-text search using PyMongo
from pymongo import Connection
if __name__ == '__main__':
# Connect to mongo
conn = Connection()
db = conn['canepi']
# Set the search term
term = 'foo'
# Run the search
results = db.command('text', 'healthmap', search=term)
# Print the results
print(results)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment