Created
May 26, 2012 02:20
-
-
Save mcantelon/2791753 to your computer and use it in GitHub Desktop.
Basic PYES
This file contains hidden or 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
from pyes import * | |
conn = ES('127.0.0.1:9200') | |
index_name = 'test4' | |
document_type = 'thing' | |
#conn.delete_index(index_name) | |
conn.create_index(index_name) | |
conn.index({ | |
"name": "Color is blue", | |
}, index_name, document_type, 1) | |
conn.index({ | |
"name": "Color is red", | |
}, index_name, document_type, 2) | |
conn.refresh() | |
q = TermQuery('name', 'color') | |
results = conn.search(query=q, indices=index_name) | |
for r in results: | |
print r |
conn.delete_index_if_exists(index_name)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Exact search (I think)
q = FieldQuery(FieldParameter('uuid', 'b53f4c8d-8ce9-4f8a-9b0b-6ed889e52336'))
Find all
q = FieldQuery(FieldParameter('uuid', '*'))