Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The "/_search" endpoint does not support URL-encoded characters in the query params #32922

Closed
Saganus opened this issue Aug 16, 2018 · 1 comment

Comments

@Saganus
Copy link

Saganus commented Aug 16, 2018

Elasticsearch version (bin/elasticsearch --version):
Version: 6.3.2, Build: default/deb/053779d/2018-07-20T05:20:23.451332Z, JVM: 1.8.0_171

Plugins installed: None

JVM version (java -version):
openjdk version "1.8.0_171"
OpenJDK Runtime Environment (build 1.8.0_171-8u171-b11-0ubuntu0.16.04.1-b11)
OpenJDK 64-Bit Server VM (build 25.171-b11, mixed mode)

OS version (uname -a if on a Unix-like system):
Linux MyHost 4.15.0-29-generic #31~16.04.1-Ubuntu SMP Wed Jul 18 08:54:04 UTC 2018 x86_64 x86_64 x86_64 GNU/Linux

Description of the problem including expected versus actual behavior:
Elasticsearch doesn't seem to support URL-encoded query params.

Running a query with e.g. the filter_path param (using an index called "2018-08-01")

curl http://localhost:9200/2018-08-01/_search?filter_path=hits.hits._source

correctly returns the expected results.

However if I encode part of, or all of the URI I get an error:

Example 1: encoding only the "?" char returns a 405 error:

curl http://localhost:9200/2018-08-01/_search%3Ffilter_path=hits.hits._source

{
  "error": "Incorrect HTTP method for uri [/2018-08-01/_search%3Ffilter_path=hits.hits._source] and method [GET], allowed: [POST]",
  "status": 405
}

Example 2: encoding only the "=" char returns an "illegal_argument_exception" error:

curl http://localhost:9200/2018-08-01/_search?filter_path%3Dhits.hits._source

{
  "error": {
    "root_cause": [
      {
        "type": "illegal_argument_exception",
        "reason": "request [/2018-08-01/_search] contains unrecognized parameter: [filter_path=hits.hits._source]"
      }
    ],
    "type": "illegal_argument_exception",
    "reason": "request [/2018-08-01/_search] contains unrecognized parameter: [filter_path=hits.hits._source]"
  },
  "status": 400
}

Example 3: encoding both query param chars returns a 405 as well:

curl http://localhost:9200/2018-08-01/_search%3Ffilter_path%3Dhits.hits._source

{
  "error": "Incorrect HTTP method for uri [/2018-08-01/_search%3Ffilter_path%3Dhits.hits._source] and method [GET], allowed: [POST]",
  "status": 405
}

Steps to reproduce:

Please include a minimal but complete recreation of the problem, including
(e.g.) index creation, mappings, settings, query etc. The easier you make for
us to reproduce it, the more likely that somebody will take the time to look at it.

  1. Install Elasticsearch 6.3.2 from a .deb package

  2. Create an index (empty or not, the error is present in both cases)
    http PUT 'localhost:9200/test'

  3. Try to query the data with an URL-encoded char in the query params
    curl http://localhost:9200/test/_search%3Ffilter_path%3Dhits.hits._source

Provide logs (if relevant):

@Saganus
Copy link
Author

Saganus commented Aug 16, 2018

It seems like the library I was using was not correctly URL-encoding the params only and instead encoding everything.

This is not a bug.

@Saganus Saganus closed this as completed Aug 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant