Skip to content
This repository has been archived by the owner on Feb 20, 2019. It is now read-only.

Make faceting on booleans return True and False instead of "T" and "F" #72

Closed
mythmon opened this issue Sep 11, 2012 · 4 comments
Closed

Comments

@mythmon
Copy link
Contributor

mythmon commented Sep 11, 2012

Consider an index with a boolean value 'happy'.

>> S().facet('happy').facet_counts()
{u'happy': [{u'count': 600, u'term': u'T'}, {u'count': 600, u'term': u'F'}]

Notice that term is "T" or "F". It would make a lot more sense for it to be True or False, considering this is a boolean field. This is because, for some reason, ElasticSearch does it this way. When interacting with this field it gives back the proper json true and false, but in facets it does not.

Can we smooth over this oddity?

@willkg
Copy link
Member

willkg commented Sep 11, 2012

This is probably a problem in pyes. EU doesn't do any conversions.

We could investigate this in pyes or just wait until after we switch to pyelasticsearch.

@mythmon
Copy link
Contributor Author

mythmon commented Sep 11, 2012

To be clear, the "T" and "F" are present when doing raw queries against ES, so it is not that pyes and/or EU are doing something wrong, but that they aren't doing anything.

@willkg
Copy link
Member

willkg commented Jan 20, 2013

I think this is a problem with ElasticSearch and I'm not really sure why it's doing what it's doing. If you use curl to hit ES, it returns this:

curl -XGET 'http://localhost:9200/elasticutilstest/elasticutilsmappingtype/_search?pretty=1' -d '{"facets": {"happy": {"terms": {"field": "happy"}}}}'
{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 4,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "elasticutilstest",
      "_type" : "elasticutilsmappingtype",
      "_id" : "4",
      "_score" : 1.0, "_source" : {"id": 4, "happy": true}
    }, {
      "_index" : "elasticutilstest",
      "_type" : "elasticutilsmappingtype",
      "_id" : "1",
      "_score" : 1.0, "_source" : {"id": 1, "happy": true}
    }, {
      "_index" : "elasticutilstest",
      "_type" : "elasticutilsmappingtype",
      "_id" : "2",
      "_score" : 1.0, "_source" : {"id": 2, "happy": true}
    }, {
      "_index" : "elasticutilstest",
      "_type" : "elasticutilsmappingtype",
      "_id" : "3",
      "_score" : 1.0, "_source" : {"id": 3, "happy": true}
    } ]
  },
  "facets" : {
    "happy" : {
      "_type" : "terms",
      "missing" : 0,
      "total" : 4,
      "other" : 0,
      "terms" : [ {
        "term" : "T",
        "count" : 4
      } ]
    }
  }

So the _source that's coming back it true/false JSON values, but in the facet counts, it's coming back as "T".

I don't think there's anything we can do here because EU can't distinguish between whether "T" is a string or a boolean value.

@willkg
Copy link
Member

willkg commented Jun 6, 2013

I thought about fixing this in pull #147, but didn't because in my research I bumped into this bug in Elasticsearch:

elastic/elasticsearch#2462

I think I'm inclined to not fix this in ElasticUtils. I'm going to close this out.

@willkg willkg closed this as completed Jun 6, 2013
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants