Unexpected token i error?


#1

Hello ElasticSearch experts,

I am a new user of ElasticSearch, I am testing with basic query below and got error of "Unexpected token i",

Does anyone have any thoughts?

{
  "query": {
    "match_all" : { }
  }
}

thanks in advance,
Lin


(David Pilato) #2

What tool are you using? Curl?

What is the exact command?


#3

Hi dadoonet,

I am using Advanced REST client in Chrome as a plug-in to send POST request. Is there any recommended curl command to try? If so, appreciate if you could share the command to me and I will have a try.

Is there anything wrong with the command itself?

regards,
Lin


(David Pilato) #4

To which URL?


#5

Hi dadoonet,

I setup a local instance which is not accessible from outside. :frowning:

For URL, anything I need to check for the issue I met with?

regards,
Lin


(David Pilato) #6

I don't understand what you are doing.

What I know from now:

  • you send a POST request from Chrome REST Client to an unknown URL
  • You try to add the following payload:
{
  "query": {
    "match_all" : { }
  }
}

I have no clue based on this too few informations what is the source of your error.
I never saw such an error: Unexpected token i

May be you can try to make a screenshot so we can understand what you are doing.


#7

Hi dadoonet,

For sure, here is the screen snapshots. Any ideas how to test further to resolve this issue is appreciated. Have a good night. :smile:

regards,
Lin


(David Pilato) #8

Change the content type
Also I still can't see what is the URL.


#9

Hi David,

Dumb question, what do you mean content type?

And if you mean the URL address, it is an internal address which cannot be accessed from out side,

http://10.10.10.123:9200/customer/sales/_search

regards,
Lin


(David Pilato) #10

You are sending your POST request using something like a FORM: application/x-www-form-urlencoded.
It's not.

It's JSON content here.


#11

Hi David,

Good catch. Any ideas how to fix it? :smile:

regards,
Lin


(David Pilato) #12

Yes. Change the value.


#13

Hi David,

You mean change "application/x-www-form-urlencoded" to what value?

regards,
Lin


(David Pilato) #14

http://www.ietf.org/rfc/rfc4627.txt says application/json. I'm pretty sure you have that in your dropdown list.


(system) #15