Git Product home page Git Product logo

Comments (5)

simonw avatar simonw commented on May 18, 2024

It's definitely still invalid JSON - the JSON spec on http://www.json.org/ is clear that double quotes are required around string values, including object keys. In practice it's not a huge problem that elasticsearch accepts invalid JSON for the queries though, provided it also accepts valid JSON. The JSON output by elasticsearch uses quotes in the right places and is absolutely fine.

Python's JSON parser is strict by default, and throws the following exception if I feed in the above example:

ValueError: Expecting property name: line 2 column 5 (char 6)

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

The invalid part I was talking about is the usage of the same field name twice within an object.

Regarding the quotes on field names, you are absolutely correct. ES does accept field names that are either quoted or not, for two reasons:

  1. Less text on the wire / simplifies writing examples :).
  2. Makes direct Javascript usage simpler.

from elasticsearch.

clintongormley avatar clintongormley commented on May 18, 2024

Actually, non-unique key names are invalid JSON. See section 2.2 in http://www.ietf.org/rfc/rfc4627.txt?number=4627

So whenever you have repeatable items, you should provide both:
{ key: value }
{ keys: [ value_1, value_n ] }

from elasticsearch.

clintongormley avatar clintongormley commented on May 18, 2024

or:

{ key: value }  | { key: [ value_1, value_n] }

from elasticsearch.

kimchy avatar kimchy commented on May 18, 2024

They say SHOULD not must :). In any case, I will make sure in the future that the SHOULD, with all its uppercase glory, is maintained :).

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.