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

[Painless Lab] Floating point values coerced to integers #60140

Closed
cjcenizal opened this issue Mar 13, 2020 · 4 comments
Closed

[Painless Lab] Floating point values coerced to integers #60140

cjcenizal opened this issue Mar 13, 2020 · 4 comments
Assignees
Labels
bug Fixes for quality problems that affect the customer experience Feature:Dev Tools Feature:Painless Lab Dev tool for learning Painless painless painless Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more

Comments

@cjcenizal
Copy link
Contributor

The API expects floating point parameters to be respected, e.g.

POST /_scripts/painless/_execute
{
  "script": {
    "source": "params.count / params.total",
    "params": {
      "count": 100.0,
      "total": 1000.0
    }
  }
}

This resolves to 0.1. However, if we set the Parameters tab to:

{
  "count": 100.0,
  "total": 1000.0
}

And then execute a script of params.count / params.total, then the request is sent with coerced integer parameters of 100 and 1000. Because they're integer values, they resolve to 0.

@cjcenizal cjcenizal added bug Fixes for quality problems that affect the customer experience Feature:Dev Tools painless painless Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more labels Mar 13, 2020
@elasticmachine
Copy link
Contributor

Pinging @elastic/es-ui (Team:Elasticsearch UI)

@cjcenizal
Copy link
Contributor Author

@jloleysens It looks like Console doesn't have this problem. Do you know why not, and do you know if we can reuse the solution here?

@cjcenizal
Copy link
Contributor Author

Looks like this is a result of parsing the parameters input as an object on the client, instead of preserving it as a string.

@cjcenizal
Copy link
Contributor Author

Closed by #60201

@cjcenizal cjcenizal added the Feature:Painless Lab Dev tool for learning Painless label Mar 23, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Fixes for quality problems that affect the customer experience Feature:Dev Tools Feature:Painless Lab Dev tool for learning Painless painless painless Team:Kibana Management Dev Tools, Index Management, Upgrade Assistant, ILM, Ingest Node Pipelines, and more
Projects
None yet
Development

No branches or pull requests

2 participants