Get just some fields of all elements using curl

Hi people.
I need some help.
I'm trying to make a query via curl to get some fields of all elements of a shard.
I've tried this command:

curl -s -H 'Content-Type: application/json' 'http://localhost:9200/video/_search?pretty=true&size=1&from=0&stored_fields=file'

return

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 6935,
    "max_score" : 1.0,
    "hits" : [
      {
        "_index" : "video",
        "_type" : "_doc",
        "_id" : "0a63bb26b0079d99267b99c2359021d5",
        "_score" : 1.0
      }
    ]
  }
}

So I've tried

curl -s -H 'Content-Type: application/json' 'http://localhost:9200/video/_search?pretty=true&size=1&from=0' -d'{"stored_fields" : ["file"]}'

same results.
Using '_source' as value like

curl -s -H 'Content-Type: application/json' 'http://localhost:9200/libri/_search?pretty=true&size=1&from=0' -d'{"stored_fields" : "_source"}'

or

curl -s -H 'Content-Type: application/json' 'http://localhost:9200/video/_search?pretty=true&size=1&from=0&stored_fields=_source

return all _source properties.
There is a way to get only some properties inside _source?

Hi @sphawk

If you look on this page...

GET my-index/_search
{
  "_source" : [ "field_1", "field_2", "other_*"]
}

Or You could use

_source_excludes
Or
_source_includes

great!

curl -s -H 'Content-Type: application/json' 'http://localhost:9200/video/_search?pretty=true&size=1&from=0' -d'{ "_source" : [ "file"] }'

work like a charm!
tnx @stephenb

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.