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

Statistical facet ignores nested documents #3209

Closed
bleskes opened this issue Jun 20, 2013 · 2 comments
Closed

Statistical facet ignores nested documents #3209

bleskes opened this issue Jun 20, 2013 · 2 comments

Comments

@bleskes
Copy link
Contributor

bleskes commented Jun 20, 2013

To reproduce, create a mapping:

curl -XPUT "http://localhost:9200/bar/" -d'
{
   "mappings": {
      "foo": {
         "properties": {
            "accounts": {
               "type": "nested"
            }
         }
      }
   }
}'

Index an object:

curl -XPOST "http://localhost:9200/bar/foo" -d'
{
   "accounts": [
      {
         "amount": 1
      }
   ]
}'

And run a search:

curl -XPOST "http://localhost:9200/bar/_search" -d'
{
   "facets": {
      "test": {
         "statistical": {
            "field": "accounts.amount"
         }
      }
   },
   "size":0
}'

This is the output (note that it did find one document, but not stats on it):

{
   "took": 90,
   "timed_out": false,
   "_shards": {
      "total": 5,
      "successful": 5,
      "failed": 0
   },
   "hits": {
      "total": 1,
      "max_score": 1,
      "hits": []
   },
   "facets": {
      "test": {
         "_type": "statistical",
         "count": 0,
         "total": 0,
         "min": "Infinity",
         "max": "-Infinity",
         "mean": 0,
         "sum_of_squares": 0,
         "variance": "NaN",
         "std_deviation": "NaN"
      }
   }
}
@uboness
Copy link
Contributor

uboness commented Jun 20, 2013

you forgot to specify "nested" on the facet:


curl -XPOST "http://localhost:9200/bar/_search" -d'
{
   "facets": {
      "test": {
         "statistical": {
            "field": "accounts.amount"
         },
         "nested" : "accounts"

      }
   },
   "size":0
}'

@bleskes
Copy link
Contributor Author

bleskes commented Jun 20, 2013

@uboness thx. Indeed. For future record - this works too and conforms to the documentation (note the field option of the facet):

curl -XPOST "http://localhost:9200/bar/_search" -d'
{
   "facets": {
      "test": {
         "statistical": {
            "field": "amount"
         },
         "nested": "accounts"
      }
   },
   "size":0
}'

@bleskes bleskes closed this as completed Jun 20, 2013
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