aboutsummaryrefslogtreecommitdiff
path: root/doc/elasticsearch.org
diff options
context:
space:
mode:
authorzsloan2018-04-04 12:15:45 -0500
committerGitHub2018-04-04 12:15:45 -0500
commitb152aca03be73655d2fb5eda17d533504ed900e2 (patch)
tree8e6b5d3810081d44b59f91e15fbf1702c444f7af /doc/elasticsearch.org
parent57e6d490cf8c7acb326552456a597f1e1cdecc2c (diff)
parent273c72ef02f839b88b3d2ad504e9d84eab0f9ec5 (diff)
downloadgenenetwork2-b152aca03be73655d2fb5eda17d533504ed900e2.tar.gz
Merge pull request #303 from pjotrp/testing
Minor edits and document on ES
Diffstat (limited to 'doc/elasticsearch.org')
-rw-r--r--doc/elasticsearch.org41
1 files changed, 41 insertions, 0 deletions
diff --git a/doc/elasticsearch.org b/doc/elasticsearch.org
new file mode 100644
index 00000000..18adfc8b
--- /dev/null
+++ b/doc/elasticsearch.org
@@ -0,0 +1,41 @@
+* Elasticsearch
+
+To get the right environment, first you can get a python REPL with something like
+
+: env GN2_PROFILE=~/opt/gn-latest ./bin/genenetwork2 ../etc/default_settings.py -cli python
+
+(make sure to use the correct GN2_PROFILE!)
+
+Next try
+
+#+BEGIN_SRC python
+
+from elasticsearch import Elasticsearch, TransportError
+
+es = Elasticsearch([{ "host": 'localhost', "port": '9200' }])
+
+# Dump all data
+
+es.search("*")
+
+# To fetch an E-mail record from the users index
+
+record = es.search(
+ index = 'users', doc_type = 'local', body = {
+ "query": { "match": { "email_address": "myname@email.com" } }
+ })
+
+# It is also possible to do wild card matching
+
+q = { "query": { "wildcard" : { "full_name" : "pjot*" } }}
+es.search(index = 'users', doc_type = 'local', body = q)
+
+# To get elements from that record:
+
+record['hits']['hits'][0][u'_source']['full_name']
+u'Pjotr'
+
+record['hits']['hits'][0][u'_source']['email_address']
+u"myname@email.com"
+
+#+END_SRC