I'm just starting to work with boto to connect to Amazon CloudSearch.
I got the examples working, but I can't find any examples of connecting to an existing domain, all the examples create a new domain.
Poking around, I found get_domain, but that fails if I call it on the connection object.
>>> conn.get_domain('foo')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
AttributeError: 'Layer2' object has no attribute 'get_domain'
Any suggestions as to how I can connect to an existing domain?
[edit] I started from this: http://boto.cloudhackers.com/en/latest/cloudsearch_tut.html
So, all I'm doing this
import boto
conn = boto.connect_cloudsearch()
This is the perfect solution. I am using boto 2.38.0
I had same issue which are faced by other. Then i made this script to connect aws search domain and get result
Let me know any error. I hope this will work for all.
Using boto 2.36, I got this working by taking a look at the source code.
I initially implemented the connection using the Layer2 approach:
Layer2(region='region name').lookup('domain name')
.However, after some profiling I found the latency in creating a connection to be very high.
When I say very high, I mean the time to create a connection was rivaling the time to actually perform the query and get a response (> 500ms in most cases).
My solution, therefore, was to create the
Domain
directly. Note: this solution is brittle, but it does decrease latency significantlyYou can create the domain by doing something like (many of these values can be found by doing
aws cloudsearch describe-domains
):You can either do
conn.list_domains()
which will return a list of Domain objects for all of your current domains or you can doconn.lookup('foo')
which will return a Domain object for the specified domain name.this worked for me,
we have only one domain,
dom = Domain(con,con.describe_domains()[0])