GithubHelp home page GithubHelp logo

Comments (4)

andreasklinger avatar andreasklinger commented on May 23, 2024 3

@defgenx thanks for getting back!

Ok got it!

The reason why this was confusing for me:

I would have expected

   must do
    bool do
      should do
        term color: red
        term color: blue
      end
    end
   end

to create

            "must": [
                {
                    "bool": {
                        "should": [
                            {"term": {"color": "red"}},
                            {"term": {"color": "blue"}}
                        ]
                    }
                }
            ]

But based on my experience so far (might be wrong) it just creates the first "term" and drops the second one silently without any error

            "must": [
                {
                    "bool": {
                        "should": [
                            {"term": {"color": "red"}},
                        ]
                    }
                }
            ]

No error message - just different json output than i'd have expected from the ruby dsl (assuming it's meant to mirror the json syntax)

must do
    bool do
      should { term color: red }
      should { term color: blue }
      end
    end
   end

creates the correct result as you described

from elasticsearch-dsl-ruby.

tonybruess avatar tonybruess commented on May 23, 2024 3

I think this issue could be solved just by improving documentation

from elasticsearch-dsl-ruby.

tonybruess avatar tonybruess commented on May 23, 2024

➕ I just ran into this same issue

from elasticsearch-dsl-ruby.

defgenx avatar defgenx commented on May 23, 2024

@andreasklinger It is by design.

Here is a link for complex queries. Maybe this can help you a little : https://github.com/elastic/elasticsearch-rails/blob/master/elasticsearch-rails/lib/rails/templates/searchable.dsl.rb#L73

You can use a terms query for your 'color' field and delete the nested bool query (not tested but I think it should work).

from elasticsearch-dsl-ruby.

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.