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

Nested sort not calculating avg/sum #2701

Closed
clintongormley opened this issue Feb 27, 2013 · 3 comments
Closed

Nested sort not calculating avg/sum #2701

clintongormley opened this issue Feb 27, 2013 · 3 comments

Comments

@clintongormley
Copy link

In 0.90.0.Beta1, while score_modes of min and max return the correct values in sort[], avg and sum don't:

curl -XPUT 'http://127.0.0.1:9200/test/?pretty=1'  -d '
{
   "mappings" : {
      "test" : {
         "properties" : {
            "foo" : {
               "type" : "nested"
            }
         }
      }
   }
}
'

curl -XPOST 'http://127.0.0.1:9200/test/test?pretty=1'  -d '
{
   "foo" : [
      {
         "val" : 10,
         "tag" : "foo"
      },
      {
         "val" : 20,
         "tag" : "bar"
      }
   ]
}
'

curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "sort" : [
      {
         "foo.val" : {
            "sort_order" : "asc",
            "sort_mode" : "sum"
         }
      }
   ]
}
'

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "foo" : [
#                   {
#                      "tag" : "foo",
#                      "val" : 10
#                   },
#                   {
#                      "tag" : "bar",
#                      "val" : 20
#                   }
#                ]
#             },
#             "sort" : [
#                10
#             ],
#             "_score" : null,
#             "_index" : "test",
#             "_id" : "kHkGLjyASUycZveKsg9Low",
#             "_type" : "test"
#          }
#       ],
#       "max_score" : null,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 4
# }


curl -XGET 'http://127.0.0.1:9200/test/test/_search?pretty=1'  -d '
{
   "sort" : [
      {
         "foo.val" : {
            "sort_order" : "asc",
            "sort_mode" : "avg"
         }
      }
   ]
}
'

# {
#    "hits" : {
#       "hits" : [
#          {
#             "_source" : {
#                "foo" : [
#                   {
#                      "tag" : "foo",
#                      "val" : 10
#                   },
#                   {
#                      "tag" : "bar",
#                      "val" : 20
#                   }
#                ]
#             },
#             "sort" : [
#                10
#             ],
#             "_score" : null,
#             "_index" : "test",
#             "_id" : "kHkGLjyASUycZveKsg9Low",
#             "_type" : "test"
#          }
#       ],
#       "max_score" : null,
#       "total" : 1
#    },
#    "timed_out" : false,
#    "_shards" : {
#       "failed" : 0,
#       "successful" : 5,
#       "total" : 5
#    },
#    "took" : 2
# }
@s1monw
Copy link
Contributor

s1monw commented Mar 1, 2013

can we close this with @martijnvg commit?

@clintongormley
Copy link
Author

No - this issue was opened after that commit.

@s1monw
Copy link
Contributor

s1monw commented Mar 1, 2013

ok just checking in... thanks @clintongormley

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants