How to include _version in scroll / scan results?

Hello ES folks!

I'd like to see _version included in the results for my scan / scroll search query. I don't see it included in the default results when I query for full records, nor if I request it in the _source array. I do see the _version when I retrieve an individual row.

Is _version available via the sroll interface? Am I doing something wrong in this query?

I originally wrote my code against a 1.x version of ES. I am using elasticsearch 2.1 in production.

Here are direct curl versions similar to our requests.

query versions

  1. search_type=scan

     #!/bin/sh
     ES_HOST=localhost
     SCROLL_ID=$(curl http://$ES_HOST:9200/resumes-test/resume/_search'?search_type=scan&scroll=10m' -d'{ "query":{ "match_all": {} }}' | jq -r '.["_scroll_id"]')
     curl http://$ES_HOST:9200/_search/scroll\?scroll\=1m -d $SCROLL_ID > scan_scroll_test.json
    
  2. scroll

     #!/bin/sh
     ES_HOST=localhost
     curl http://$ES_HOST:9200/resumes-test/resume/_search'?scroll=1m' -d '{"query":{"match_all": {}}}' > scroll_test.json
    

results

  1. scan_scroll_test.json

     {
       "_scroll_id": "c2NhbjswOzE7dG90YWxfaGl0czoxOw==",
       "took": 2,
       "timed_out": false,
       "_shards": {
         "total": 30,
         "successful": 30,
         "failed": 0
       },
       "hits": {
         "total": 1,
         "max_score": 0,
         "hits": [
           {
             "_index": "resume-test-20160115",
             "_type": "resume",
             "_id": "46480b1a",
             "_score": 0,
             "_source": { ... }
           }]}
     }
    
  2. scroll_test.json

     {
       "_scroll_id": "cXVlcnlUaGVuRmV0Y2g7MzA7MjE5ODg0OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE5ODg1OjhvU0lYbTN1UkxlYTdYQlY3WU5
     WTVE7MjE4MDQ1OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODg2OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDQwOjZ5aVVSanRYU3htbWdpSDl
     kX2VZamc7MjE5ODkwOjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE5ODg3OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDQzOjZ5aVVSanRYU3htbWd
     pSDlkX2VZamc7MjE4MDQxOjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODkzOjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDQyOjZ5aVVSanRYU3h
     tbWdpSDlkX2VZamc7MjE4MDQ0OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODkyOjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE5ODg4OjhvU0lYbTN
     1UkxlYTdYQlY3WU5WTVE7MjE4MDQ2OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE4MDQ3OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODk0OjhvU0l
     YbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDQ5OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE4MDUwOjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODk1Ojh
     vU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDQ4OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODg5OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE5ODkxOjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE5ODk3OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDU0OjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODk2OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDUzOjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE4MDUxOjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MjE5ODk4OjhvU0lYbTN1UkxlYTdYQlY3WU5WTVE7MjE4MDUyOjZ5aVVSanRYU3htbWdpSDlkX2VZamc7MDs=",
       "took": 7,
       "timed_out": false,
       "_shards": {
         "total": 30,
         "successful": 30,
         "failed": 0
       },
       "hits": {
         "total": 1,
         "max_score": 1,
         "hits": [
           {
             "_index": "resume-test-20160115",
             "_type": "resume",
             "_id": "46480b1a",
             "_score": 1,
             "_source": { ... } 
           }]}
     }
    
  3. raw document

    curl http://$ES-HOST:9200/resumes-test/resume/46480b1a

    {
      "_index" : "resume-test-20160115",
      "_type" : "resume",
      "_id" : "46480b1a",
      "_version" : 1,
      "found" : true",
      "_source":{ ... }
    }

Wow, is it really just that I was missing "version": true in my request?

[ref: http://stackoverflow.com/a/24731855/117714 ]