rhsimplex / image-match

🎇 Quickly search over billions of images
2.94k stars 405 forks source link

Connect to remote Elasticsearch instance? #116

Closed Davidramsey03 closed 5 years ago

Davidramsey03 commented 5 years ago

I have this working locally fine, and have built a python GUI for interacting with it, which also works.

I'm working on our deployment plans, and I'd like to have the python app installed on each machine, and the elasticsearch DB remote on a server. Is there somewhere in the code for this that I can set a different location for the ES database? I've looked through and am not finding anything outside of the docker files.

drakerc commented 5 years ago

I'm not sure if that's what you mean, but you configure your Elasticsearch instance when initializing the SignatureES. E.g.:

        es = Elasticsearch([{'host': 'elasticsearch, 'port': 9200}])
        ses = SignatureES(es, index='images')

Then you use ses to do everything, like ses.add_image() or ses.search_image()

Davidramsey03 commented 5 years ago

Hey there, yeah that's exactly what I meant.

Just last night I finally managed to get it connected. I had the idea of following the imports back to elasticsearch module and seeing what was there. That led to some great info. I just wish there was some more documentation so I didn't have to spend so much time digging for the project, but at least it's working now. Thanks for your help.

If anyone wants to know my solution, it's below.

In python, to see where the es module was coming from, I did:

import inspect
print(inspect.getfile(Elasticsearch))

Navigating to the printed directory, I found an "init.py" file, with a large comment block giving some good usage examples.

Back in python, I then did similar to what you commented: es = Elasticsearch([ 'MYSERVERIP:PORT' ])

then ran a test adding a small subset of my data then retrieving it successfully, verifying also with Postman request.