annoyingmouse
annoyingmouse

Reputation: 5699

Cloudsearch via API Gateway not returning results, issue with URL encoding?

I'm running into an issue with Cloudsearch and AWS API Gateway. I have a Cloudsearch domain with details of cheeses (Don't ask ;-) ) and I can query cheeses fine using the test search console and via my API Gateway as long as the query is Simple:

q=feta&q.parser=simple&q.options={"fields":["cheeseid"]}

And I can do the same via the Console if it's Structured, like this:

q=(and cheeseid:'feta')&q.parser=structured

But the same query doesn't work via API Gateway. For instance, this query (via the browser-based application):

q=(and+cheeseid%3A%27feta%27)&q.parser=structured

returns no results despite it being exactly the same when URL decoded.

Interestingly the output of the Raw Search Results via the console have this:

q=(and+cheeseid%3A'feta')&q.parser=structured

which makes me thing that the ' shouldn't be encoded but I'm not sure how to implement this as I've tried passing the raw string without processing and have met with the same result.

If someone could point me in the right direction I'd be very grateful as I'm banging my head against a brick wall here trying to find my cheeses!

Upvotes: 1

Views: 531

Answers (1)

MikeD at AWS
MikeD at AWS

Reputation: 3745

The URL encoded version of your query is not correct. The parenthesis characters () also need to be encoded. Assuming that this is passed as the query string, then the URL encoded from should look like this:

q=%28and+cheeseid%3A%27feta%27%29&q.parser=structured

If that doesn't work then please test your method via test invoke in the API Gateway console and post the full debug output.

Upvotes: 2

Related Questions