Allow support of boost (and other options) to Terms Query #643

Closed
wants to merge 2 commits into
from

Projects

None yet

3 participants

@moktin
moktin commented Feb 26, 2013

Hi,

While using tire, I had problem using the boost on query terms.

I am pretty new to both tire and elasticsearch world, so maybe I am just doing it wrong.

With this indices

class User < ActiveRecord::Base
  include Tire::Model::Search
  mapping do
    indexes :comments do
      indexes :id, type: :integer
    end
  end
end

A request like :

search = User.search do
  query do
    boolean do
      should { 
        terms 'comments.id',  [1, 2], boost: 10
      }
    end
  end
end

produce such a result :

curl -X GET 'http://localhost:9200/users/user/_search?load=true&size=12&pretty' -d '
  {
    "query": {
      "bool": {
        "should": [
          {
            "terms": {
              "comments.id": [
                1,2
              ]
            }
          }
        ]
      }
    },
    "size": 12
  }
'

When I was waiting for something like that :

curl -X GET 'http://localhost:9200/users/user/_search?load=true&size=12&pretty' -d '
  {
    "query": {
      "bool": {
        "should": [
          {
            "terms": {
              "comments.id": [
                1,2
              ],
              "boost": 10
            }
          }
        ]
      }
    },
    "size": 12
  }
'

The attached pull request solve that.

Thank you to let me know if it helps or if you need some more informations

@brupm
brupm commented Feb 26, 2013

👍 Very useful PR. Although the build is failing.

@moktin
moktin commented Feb 26, 2013

Hi,
The test are green locally :

Finished in 173.233226 seconds.

774 tests, 774 passed, 0 failures, 0 errors, 0 skips, 1745 assertions

I also noticed that most of the past builds on Travis are failing (see https://travis-ci.org/karmi/tire/builds) and it seems to be exactly the same errors.

@karmi are the builds having general problem on travis ? Or are they "real" failure ?

@karmi karmi added a commit that referenced this pull request Mar 27, 2013
@moktin moktin Allow options for the `terms` query
Closes: #643
8db77cd
@karmi
Owner
karmi commented Mar 27, 2013

Thanks!, merged & pushed.


Re the Travis failures -- there has been some incompatibilites with Ruby 1.8, which were shooting down the tests, and the percolator tests are still failing consistently. I have tried to fix it in 1a8b921, but will need to have a better look into it.

@karmi karmi closed this Mar 27, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment