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

inner_hits - possible to have search_type set to count? #10358

Closed
jaddison opened this issue Mar 31, 2015 · 5 comments
Closed

inner_hits - possible to have search_type set to count? #10358

jaddison opened this issue Mar 31, 2015 · 5 comments

Comments

@jaddison
Copy link

I tried setting the inner_hits size option to 0, but this causes an exception. Will it be possible to ONLY get back total matching inner hits, like we can with normal queries with http://www.elastic.co/guide/en/elasticsearch/reference/1.4/search-request-search-type.html#count?

@martijnvg
Copy link
Member

@jaddison This looks like a bug, you should be able to set size to 0 on the inner_hit definition. Can you share the exception and possible also a reproduction?

Inner hits is a fetch phase feature. When setting search_type to count the fetch phase doesn't get executed, so that is why inner_hits don't work with that search_type.

@jaddison
Copy link
Author

jaddison commented Apr 1, 2015

With this query:

POST /activities/location/_search
{
    "query": {
        "has_child": {
            "type": "classes",
            "query": {"match_all": {}},
            "inner_hits": {"size": 0}
        }
    }
}

Here's the result:

{
   "took": 7,
   "timed_out": false,
   "_shards": {
      "total": 9,
      "successful": 8,
      "failed": 1,
      "failures": [
         {
            "index": "activities-20150326-154425",
            "shard": 0,
            "status": 500,
            "reason": "IllegalArgumentException[numHits must be > 0; please use TotalHitCountCollector if you just need the total hit count]"
         }
      ]
   },
   "hits": {
      "total": 586,
      "max_score": 1,
      "hits": []
   }
}

@martijnvg
Copy link
Member

This is odd, inner_hits itself doesn't use TotalHitCountCollector...
On what ES version are you running this query? (snapshot?)

@jaddison
Copy link
Author

jaddison commented Apr 1, 2015

{
   "status": 200,
   "name": "Miek",
   "cluster_name": "elasticsearch",
   "version": {
      "number": "1.5.0",
      "build_hash": "544816042d40151d3ce4ba4f95399d7860dc2e92",
      "build_timestamp": "2015-03-23T14:30:58Z",
      "build_snapshot": false,
      "lucene_version": "4.10.4"
   },
   "tagline": "You Know, for Search"
}

@martijnvg
Copy link
Member

@jaddison I must have overlooked something last night... I opened a PR: #10388

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