boto3 cloudsearch: can create domain and indices, cannot set domain or endpoint for search or upload

1,043 views
Skip to first unread message

Chris Shenton

unread,
May 14, 2015, 5:43:14 PM5/14/15
to boto-...@googlegroups.com
[I accidentally posted this to boto-dev, too many tabs, apologize for the rephrase here but thankfully the -dev group suppressed it]

Another user made a query about boto3 and cloudsearch but I haven't found anything besides this reference:


I can create a cloudsearch domain and indices fine, like:

INDICES = [
   
{"IndexFieldName": FIELD_MAP["NASA ID"],
     
"IndexFieldType": "literal",
     
"LiteralOptions": {
         
"FacetEnabled": True,
         
"ReturnEnabled": RETURN_ENABLED,
         
"SearchEnabled": True,
         
"SortEnabled": True,
     
}},
...
]
cloudsearch
= boto3.client("cloudsearch")
domain
= cloudsearch.create_domain(DomainName=SEARCH_DOMAIN_NAME)
cloudsearch
.update_service_access_policies(
   
DomainName=SEARCH_DOMAIN_NAME,
   
AccessPolicies=json.dumps(ACCESS_BY_IP),
)
for index in INDICES:
    cloudsearch
.define_index_field(DomainName=SEARCH_DOMAIN_NAME,
                                   
IndexField=index)



and I see it PROCESSING in the console, then I an tell it to reindex. Good so far. 

But I can't figure out how to use "cloudsearchdomain" to query or upload to the domain. I don't see any way to specify my domain or its endpoint. The docs say to use the "search" endpoint for searchy stuff, and the "docs" endpoint for uploading, but no way to pass those to boto3.

From the boto3 docs:

cloudsearchdomain = boto3.client('cloudsearchdomain')
response
= client.search(query='string')



I presume the first line should say 'client =', not 'cloudsearchdomain' since 'client' is used in all the other examples. But there's no place to specify my domain's name, nor provide the domain-specific endpoint the docs discuss. The first line works, then the second fails:


>>> client = boto3.client('cloudsearchdomain')
>>> response = client.search(query='i want to believe')
botocore
.exceptions.EndpointConnectionError: Could not connect to the endpoint URL: "https://cloudsearchdomain.us-east-1.amazonaws.com/2013-01-01/search?format=sdk&pretty=true&q=i%20want%20to%20believe"



If I guess that in the docs 'cloudsearchdomain' was really supposed to be the name of my cloudsearch domain, "avail-search-20150513", the client() call fails. It also fails if I try and use various forms of the endpoint:

>>> client = boto3.client('avail-search-20150513')
botocore
.exceptions.ApiVersionNotFoundError: Unable to load data aws/avail-search-20150513 for: None

>>> client = boto3.client('search-avail-search-20150513-4dkveqihyqmovet7ahkvssbgzu.us-east-1.cloudsearch.amazonaws.com')
botocore
.exceptions.ApiVersionNotFoundError: Unable to load data aws/search-avail-search-20150513-4dkveqihyqmovet7ahkvssbgzu.us-east-1.cloudsearch.amazonaws.com for: None

>>> client = boto3.client('http://search-avail-search-20150513-4dkveqihyqmovet7ahkvssbgzu.us-east-1.cloudsearch.amazonaws.com')
botocore
.exceptions.ApiVersionNotFoundError: Unable to load data aws/http://search-avail-search-20150513-4dkveqihyqmovet7ahkvssbgzu.us-east-1.cloudsearch.amazonaws.com for: None


What am I missing? I presume the documented client() call gets a client, but somehow I need to get a connection to my domain's endpoint for the .search() to query.

Thanks for any clues you can provide.

费城

unread,
Jul 22, 2015, 10:28:54 AM7/22/15
to boto-users
client = boto3.client('cloudsearchdomain', endpoint_url='http://search-avail-search-20150513-4dkveqihyqmovet7ahkvssbgzu.us-east-1.cloudsearch.amazonaws.com')


在 2015年5月15日星期五 UTC+8上午5:43:14,Chris Shenton写道:
Reply all
Reply to author
Forward
0 new messages