AntonShuvaev / elasticsearch4idea

Elasticsearch Plugin for JetBrains IDEs
https://plugins.jetbrains.com/plugin/14512-elasticsearch
59 stars 8 forks source link

Shorthand term queries not executing in a similar manner to kibana #123

Closed Banashek closed 10 months ago

Banashek commented 1 year ago

Describe the bug Shorthand term queries appear to not be sending correctly

Steps to reproduce I have a fairly simple term query I'm attempting through the query console, but it seems to not have an optimization that I see in the kibana query console.

Example query:

GET /myindex/_search
{
  "from": 0,
  "size": 50,
  "query": {
    "bool": {
      "must": {
        "term": {
          "my_field": 1
        }
      }
    }
  }
}

Note that the above term does not explicitly have the name of the field as an object underneath it, but as a simple property.

Compare:

"term": {
  "my_field": 1
}

vs the ElasticSearch documented:

"term": {
  "my_field": {
    "value": "1"
  }
}

When the query is sent, this term appears to not be sent at all (I receive all results back).

Expected behavior That the result behavior would be similar to kibana, or that I would be notified that the clause in question would be ignored.

Environment information:

AntonShuvaev commented 1 year ago

Thank you for reporting this issue.

Both shorthand and verbose forms of term queries should work identically in Elasticsearch. The format of "term": {"my_field": "1"} and "term": {"my_field": {"value": "1"}} should give the same result. However, I noticed that you've used 1 (an integer) in your shorthand form and "1" (a string) in your verbose form. This could explain why you're seeing different behaviors.

The plugin sends the request JSON body as it is, without any modifications. If you believe the plugin is modifying the JSON request, please provide more details so I can further investigate.