Skip to content
This repository has been archived by the owner on Sep 21, 2021. It is now read-only.

Invalid Sense example code #128

Open
w33ble opened this issue Jul 16, 2014 · 4 comments
Open

Invalid Sense example code #128

w33ble opened this issue Jul 16, 2014 · 4 comments

Comments

@w33ble
Copy link

w33ble commented Jul 16, 2014

I first noticed this in /080_Structured_Search/05_term.asciidoc - The following example is in the docs, but it doesn't work when you try to copy and paste it into Sense, and the link to view in Sense actually sends different content.

Docs (results in an error, text is not passed to the request)

GET /my_store/_analyze?field=productID
XHDK-A-1293-#fJ3

note: the request is not escaped (# vs %23), so even if you fix the syntax, you get different results (the content from # on is dropped) - perhaps this should also be pointed out in the docs.

Sense

GET /my_store/_analyze?field=productID&text=XHDK-A-1293-%23fJ3

This is also an issue with the code in /052_Mapping_Analysis/40_Analysis.asciidoc and I suspect in other parts of the docs as well.

It's possible this is actually a Sense bug, but someone took the time to update the Sense json in the docs without updating the examples, and the docs are technically broken as-is.

@clintongormley
Copy link
Contributor

Hi @w33ble

Yes... This is a tricky one. Elasticsearch can accept plain text in the body, eg:

curl localhost:9200/_analyze?analyzer=standard -d '
Text to analyze here
'

This is a much clearer syntax for explanation purposes than:

curl localhost:9200/_analyze?analyzer=standard&text=Text%20to%20analyze%20here

However, Sense can only handle JSON bodies, not plain text. With a JSON body it knows where the end of the body should be. A plain text body might include paragraphs, so where does the body actually end?

There is an open issue (elastic/elasticsearch#5866) to allow the analyze end point to accept JSON instead of text, which would solve this issue.

@w33ble
Copy link
Author

w33ble commented Jul 17, 2014

Cool, thanks for the feedback. Curious: is analyze the only command that's takes text instead of JSON?

@clintongormley
Copy link
Contributor

No, there are the scroll and clear scroll APIs too, but those are less problematic.

@sxbo672158
Copy link

Just curious how do I do scroll api in Sense then? Thanks,

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants