2

I am trying to access AWS elastic search (not the normal Elastic which could be hosted on some machine, but the AWS version of Elastic) using java. One thing I have identified is that we have to use REST TEMPLATE instead of the TransportClient method as AWS ES is hosted on port 80 and to get the data, we have to send a POST request with payload.

I am able to get simple data in this process but the request doesn't take wild card characters. It gives me below error:

{"type":"parse_exception","reason":"Failed to derive xcontent"}

Questions:
1. Is my understanding correct about Java hitting AWS ES on port 80? Does this mean we have to use POST instead of GET to send requests having attribute level filtering?

  1. Is there a way to pass the attribute to the elastic search in the url itself? I have tried below example which doesn't work e.g. : http://helloworld.amazon.com/customer/_search?q=emailID:*abc@gmail.*

  2. How do we pass wildcard character via java client to AWS ES to fetch the data?

Divyesh Kalbhor
  • 385
  • 3
  • 19
  • 1
    Based on the [URI Search docs](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-uri-request.html), it looks like you just need to add the parameter `analyze_wildcard=true` for wildcards and prefix queries to be supported. – dmbaughman Jul 26 '18 at 21:27
  • @dmbaughman : Your comment helped me in this. I can now pass wildcard character in the uri. One more question I have is regarding the spaces in the URI. Right now, I have spaces in the attribute values and if I create URi with "%20" as space, it searches for both the values separately in ES. Any idea about that? – Divyesh Kalbhor Jul 30 '18 at 05:42
  • 1
    If you're building the URI in Java (not just testing in a web browser or something) then you probably don't need to worry about URI-encoding the query itself--the SDK should take care of that for you. If not, using `+` signs usually works for replacing spaces in a query. But I'd try just leaving the spaces alone, unless you've already tried that and found that it doesn't work. – dmbaughman Jul 31 '18 at 20:38

0 Answers0