Dear all.
i have below in python but that one static value passed.
but need access the same code from services in dynamic way.
Import Elasticsearch package
from elasticsearch import Elasticsearch
Connect to the elastic cluster
es=Elasticsearch([{'host':'localhost','port':9200}]) #http://127.0.0.1:9200
print("connection has been done here")
res=es.get(index='megacorp',doc_type='employee',id='4')
print("you read data is:",res)
print("-----------------------------------------------------------")
print(res['_source'])
Hi @pjanzen
Thanks but in this page ,they are proving value in static manner.means not in dynamic way:-
For Example:-
res= es.search(index='megacorp',body={
'query':{
'bool':{
'must':{
'match':{
'first_name':'nitin'
}
},
"filter":{
"range":{
"age":{
"gt":25
}
}
}
}
}
})
print res['hits']['hits']
HERE:- provided first_name':'nitin' this is static way...but want to access any name: matching with Elasticsearch.
I have a query which I execute and I do something with result.
if I have more the 1000 records I need to use the scroll function to collect all information.
I have a prepared query (like what you have) and I update the the field with the data I am searching for. In your example that would be first_name. Once the query is updated you can execute it and retrieve the result.
So you need to think about your use case and if at possible share that here. If you already have developed any code please share that as well, I might be useful to help your case.
Apache, Apache Lucene, Apache Hadoop, Hadoop, HDFS and the yellow elephant
logo are trademarks of the
Apache Software Foundation
in the United States and/or other countries.