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

indices_boost seems to have no effect #137

Closed
clintongormley opened this issue Apr 16, 2010 · 2 comments
Closed

indices_boost seems to have no effect #137

clintongormley opened this issue Apr 16, 2010 · 2 comments

Comments

@clintongormley
Copy link

Hiya

Maybe I'm testing the wrong thing, but it doesn't look like indices_boost is having any effect:

Load this data:

curl -XPUT 'http://127.0.0.2:9200/es_test_1/'  -d '
{}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/'  -d '
{}
'
curl -XPUT 'http://127.0.0.2:9200/_all/type_1/_mapping'  -d '
{
   "_all" : {
      "store" : "yes",
      "term_vector" : "with_positions_offsets"
   },
   "properties" : {
      "num" : {
         "store" : "yes",
         "type" : "integer"
      },
      "date" : {
         "format" : "yyyy-MM-dd HH:mm:ss",
         "type" : "date"
      },
      "text" : {
         "store" : "yes",
         "type" : "string"
      }
   }
}
'
curl -XPUT 'http://127.0.0.2:9200/_all/type_2/_mapping'  -d '
{
   "_all" : {
      "store" : "yes",
      "term_vector" : "with_positions_offsets"
   },
   "properties" : {
      "num" : {
         "store" : "yes",
         "type" : "integer"
      },
      "date" : {
         "format" : "yyyy-MM-dd HH:mm:ss",
         "type" : "date"
      },
      "text" : {
         "store" : "yes",
         "type" : "string"
      }
   }
}
'
curl -XPOST 'http://127.0.0.2:9200/_refresh' 
curl -XGET 'http://127.0.0.2:9200/_cluster/health?timeout=2s&wait_for_status=green' 
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/1/_create'  -d '
{
   "num" : "2",
   "date" : "2010-04-2 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/2/_create'  -d '
{
   "num" : "3",
   "date" : "2010-04-3 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/3/_create'  -d '
{
   "num" : "4",
   "date" : "2010-04-4 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/4/_create'  -d '
{
   "num" : "5",
   "date" : "2010-04-5 00:00:00",
   "text" : "foo"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/5/_create'  -d '
{
   "num" : "6",
   "date" : "2010-04-6 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/6/_create'  -d '
{
   "num" : "7",
   "date" : "2010-04-7 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/7/_create'  -d '
{
   "num" : "8",
   "date" : "2010-04-8 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/8/_create'  -d '
{
   "num" : "9",
   "date" : "2010-04-9 00:00:00",
   "text" : "foo bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/9/_create'  -d '
{
   "num" : "10",
   "date" : "2010-04-10 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/10/_create'  -d '
{
   "num" : "11",
   "date" : "2010-04-11 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/11/_create'  -d '
{
   "num" : "12",
   "date" : "2010-04-12 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/12/_create'  -d '
{
   "num" : "13",
   "date" : "2010-04-13 00:00:00",
   "text" : "foo bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/13/_create'  -d '
{
   "num" : "14",
   "date" : "2010-04-14 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/14/_create'  -d '
{
   "num" : "15",
   "date" : "2010-04-15 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/15/_create'  -d '
{
   "num" : "16",
   "date" : "2010-04-16 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/16/_create'  -d '
{
   "num" : "17",
   "date" : "2010-04-17 00:00:00",
   "text" : "bar baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/17/_create'  -d '
{
   "num" : "18",
   "date" : "2010-04-18 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/18/_create'  -d '
{
   "num" : "19",
   "date" : "2010-04-19 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/19/_create'  -d '
{
   "num" : "20",
   "date" : "2010-04-20 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/20/_create'  -d '
{
   "num" : "21",
   "date" : "2010-04-21 00:00:00",
   "text" : "baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/21/_create'  -d '
{
   "num" : "22",
   "date" : "2010-04-22 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/22/_create'  -d '
{
   "num" : "23",
   "date" : "2010-04-23 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/23/_create'  -d '
{
   "num" : "24",
   "date" : "2010-04-24 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/24/_create'  -d '
{
   "num" : "25",
   "date" : "2010-04-25 00:00:00",
   "text" : "bar"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_1/25/_create'  -d '
{
   "num" : "26",
   "date" : "2010-04-26 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_1/type_2/26/_create'  -d '
{
   "num" : "27",
   "date" : "2010-04-27 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_1/27/_create'  -d '
{
   "num" : "28",
   "date" : "2010-04-28 00:00:00",
   "text" : "foo baz"
}
'
curl -XPUT 'http://127.0.0.2:9200/es_test_2/type_2/28/_create'  -d '
{
   "num" : "29",
   "date" : "2010-04-29 00:00:00",
   "text" : "foo baz"
}
'
curl -XPOST 'http://127.0.0.2:9200/_refresh' 
curl -XGET 'http://127.0.0.2:9200/_cluster/health?timeout=2s&wait_for_status=green' 

Then try these queries:

curl -XGET 'http://127.0.0.2:9200/_all/_search?pretty=true'  -d '
{
   "sort" : [
      "score"
   ],
   "fields" : [],
   "query" : {
      "field" : {
         "text" : "foo"
      }
   },
   "explain" : 0,
   "indices_boost" : {
      "es_test_2" : 0.1,
      "es_test_1" : 5000
   },
   "size" : 2
}
'

and

curl -XGET 'http://127.0.0.2:9200/_all/_search?pretty=true'  -d '
{
   "sort" : [
      "score"
   ],
   "fields" : [],
   "query" : {
      "field" : {
         "text" : "foo"
      }
   },
   "explain" : 0,
   "indices_boost" : {
      "es_test_2" : 5000,
      "es_test_1" : 0.1
   },
   "size" : 2
}
'

They both return:

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_index" : "es_test_1",
#             "_id" : "2",
#             "_type" : "type_2"
#          },
#          {
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2"
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }

I would have thought that they would have returned the same docs, but in the opposite order. Instead, they both return the docs in the same order: (without the fields param):

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "num" : "3",
#                "text" : "foo",
#                "date" : "2010-04-3 00:00:00"
#             },
#             "_index" : "es_test_1",
#             "_id" : "2",
#             "_type" : "type_2"
#          },
#          {
#             "_source" : {
#                "num" : "5",
#                "text" : "foo",
#                "date" : "2010-04-5 00:00:00"
#             },
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2"
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }

When i do an explain, it seems to be taking the boost into account, at least for one index:

curl -XGET 'http://127.0.0.2:9200/_all/_search?pretty=true'  -d '
{
   "sort" : [
      "score"
   ],
   "fields" : [],
   "query" : {
      "field" : {
         "text" : "foo"
      }
   },
   "explain" : 1,
   "indices_boost" : {
      "es_test_2" : 5000,
      "es_test_1" : 0.1
   },
   "size" : 2
}
'
# {
#    "hits" : {
#       "hits" : [
#          {
#             "_index" : "es_test_1",
#             "_id" : "2",
#             "_type" : "type_2",
#             "_explanation" : {
#                "value" : 1.287682,
#                "details" : [
#                   {
#                      "value" : 1,
#                      "description" : "tf(termFreq(text:foo)=1)"
#                   },
#                   {
#                      "value" : 1.287682,
#                      "description" : "idf(docFreq=2, maxDocs=4)"
#                   },
#                   {
#                      "value" : 1,
#                      "description" : "fieldNorm(field=text, doc=0)"
#                   }
#                ],
#                "description" : "fieldWeight(text:foo in 0), product of:"
#             }
#          },
#          {
#             "_index" : "es_test_2",
#             "_id" : "4",
#             "_type" : "type_2",
#             "_explanation" : {
#                "value" : 1.1823214,
#                "details" : [
#                   {
#                      "value" : 0.99999994,
#                      "details" : [
#                         {
#                            "value" : 5000,
#                            "description" : "boost"
#                         },
#                         {
#                            "value" : 1.1823215,
#                            "description" : "idf(docFreq=4, maxDocs=6)"
#                         },
#                         {
#                            "value" : 0.00016915871,
#                            "description" : "queryNorm"
#                         }
#                      ],
#                      "description" : "queryWeight(text:foo^5000.0), product of:"
#                   },
#                   {
#                      "value" : 1.1823215,
#                      "details" : [
#                         {
#                            "value" : 1,
#                            "description" : "tf(termFreq(text:foo)=1)"
#                         },
#                         {
#                            "value" : 1.1823215,
#                            "description" : "idf(docFreq=4, maxDocs=6)"
#                         },
#                         {
#                            "value" : 1,
#                            "description" : "fieldNorm(field=text,doc=0)"
#                         }
#                      ],
#                      "description" : "fieldWeight(text:foo in 0),product of:"
#                   }
#                ],
#                "description" : "weight(text:foo^5000.0 in 0), product of:"
#             }
#          }
#       ],
#       "total" : 16
#    },
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 10,
#       "total" : 10
#    }
# }
@kimchy
Copy link
Member

kimchy commented Apr 19, 2010

I fixed it just now in #143, and now the boost per index is actually a boost factor (the explanation reflects that as well...). Can you verify that it works for you?

@kimchy
Copy link
Member

kimchy commented May 28, 2010

ok, closing this, it should work (have tests). If not, reopen...

tlrx added a commit that referenced this issue Jun 5, 2015
Closes #136
ClaudioMFreitas pushed a commit to ClaudioMFreitas/elasticsearch-1 that referenced this issue Nov 12, 2019
Use openjdk-8-jre-headless, if ubuntu >= 15.10
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants