elastic / elasticsearch-rails

Elasticsearch integrations for ActiveModel/Record and Ruby on Rails
Apache License 2.0
3.07k stars 797 forks source link

Elasticsearch - Unexpected Character Error (Minus Sign) #1066

Open marketyler opened 10 months ago

marketyler commented 10 months ago

I am attempting to make a REST call to Elastasearch but am getting the below error message:

{"error":{"root_cause":[{"type":"x_content_parse_exception","reason":"[1:3] Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 3]"}],"type":"x_content_parse_exception","reason":"[1:3] Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 3]","caused_by":{"type":"json_parse_exception","reason":"Unexpected character ('-' (code 45)) in numeric value: expected digit (0-9) to follow minus sign, for valid numeric value\n at [Source: (org.elasticsearch.common.io.stream.ByteBufferStreamInput); line: 1, column: 3]"}},"status":400}

Background: I am trying to pass the json below. But continually get the parsing error that there is a minus sign somewhere. I can take the serialized Json that I am using and put it in Postman and I get results. However, using a RestClient is causing this error. We also use it when running through MuleSoft, also no error. What is different about RestClient? I do not see any minus signs anywhere. You will note in the example below that there are minus signs in the filter and match. however, when I remove them, I still get the parse error. Any help would be appreciated.

{ "size": 10, "query": { "bool": { "must": [ { "match": { "host.name.terms.value": "wtclth3002" } } ], "filter": [ { "range": { "@timestamp.date_histogram.timestamp": { "gte": "now-2d/d", "lte": "now/d" } } } ] } } }

picandocodigo commented 10 months ago

Hi @marketyler, Which version of the client are you using? And which client? RestClient suggests maybe the Java Elasticsearch client?

It would help if you could share the code where you're defining the JSON and passing it to the client. Thanks!