Git Product home page Git Product logo

Comments (8)

JoranDox avatar JoranDox commented on May 18, 2024 5

Has this been intentionally reverted? It seems according to https://www.elastic.co/guide/en/elasticsearch/reference/current/boolean.html and experimentally walking into it, that boolean type doesn't support 0 and 1 anymore.

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

In JSON there is a specific type for boolean, its funny that its hard to set it. So, how do you imaging this, as {"explain" : "1"} or {"explain" : 1}?

from elasticsearch.

clintongormley avatar clintongormley commented on May 18, 2024

well, in dynamic languages that don't have a boolean type (eg Perl), false is

  • 0
  • undef / null
  • ""
  • "0"

and everything else is true.

Typically, we'd pass in 1 and 0 to represent true and false, but users could pass in anything. The one gotcha could be if they pass in 'true' or 'false', which would become "true" or "false", but at least in Perl users would be unlikely to do that.

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

Ok, make sense. So, places where I parse the JSON and know what to expect, I can take care of that. But, how to you index a JSON document, are the boolean fields there used, or do you use numbers?

from elasticsearch.

clintongormley avatar clintongormley commented on May 18, 2024

Hmm, that's an interesting one...

Typically, most Perl users would use 1 / 0 (so Int). The module I'm using to encode the JSON provides the facility to represent a real JSON 'true' or 'false' by using \1 or \0 (which actually means "a reference to the scalar value 1")

Are you able to convert truthy/falsey values to real boolean values when indexing a field mapped as type: "boolean" ? If so, you may not want to enable it by default, so that users of typed languages don't complain.

But allow dynamic languages to pass a flag, perhaps?

And I'd put a a big GOTCHA warning in my docs explaining the need to use mappings before indexing.

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

I do perform optimization when it comes to boolean fields. People can use 1 and 0, but they will be treated automatically as numbers when not explicitly defined in mapping. Even when explicitly defined in the mappings as boolean, only a boolean type is supported. I will add support for numbers as well.

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

Opened #33 for the boolean type in JSON documents indexed.

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

Accept also 0 int number to indicate false, and any other number to indicate true (on top of accepting json boolean type), closed by 3f045de.

from elasticsearch.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.