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

Add support for .empty to expressions, and some docs improvements #18077

Closed
wants to merge 1 commit into from

Conversation

rmuir
Copy link
Contributor

@rmuir rmuir commented Apr 30, 2016

Its possible to treat missing values as something else other than zero today, but its not intuitive: e.g. you can do it with something like doc['field'].count() == 0 ? 500 : doc['field'].

There are two problems with this:

  • aggregate methods on fields don't seem to be documented anywhere.
  • its not as intuitive as .empty, making it inconsistent with other scripting languages.

I think we should fix both of these: we should document count()/max()/avg()/sum()/min()/etc so that people can work better with multi-valued fields, and we should syntactic sugar (.empty) to make handling empty cases easier.

@rmuir
Copy link
Contributor Author

rmuir commented Apr 30, 2016

Here is a quick hack. It required some refactoring, as we didnt really have things logically organized to support "variables" other than .value. @jdconrad can you look at this?

@rmuir
Copy link
Contributor Author

rmuir commented Apr 30, 2016

as far as the re-organization, i had in mind we may want to support some other "variables" that the other script engines support besides just .value and .empty. For example, maybe simple additions like .lat/.lon so that geo fields can start to work with expressions too?

@rmuir
Copy link
Contributor Author

rmuir commented Apr 30, 2016

Another TODO: in the docs. They emphasize Only numeric fields may be accessed but i don't think its necessarily clear that date fields will work too. I doubt most people immediately jump to the conclusion that date fields are numbers too, except us.

@jdconrad
Copy link
Contributor

LGTM. Thanks for adding this!

@rmuir rmuir closed this in 28409e4 May 2, 2016
@clintongormley clintongormley added :Core/Infra/Scripting Scripting abstractions, Painless, and Mustache and removed :Expressions labels Feb 14, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
:Core/Infra/Scripting Scripting abstractions, Painless, and Mustache >enhancement v5.0.0-alpha3
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants