# Get just some fields of all elements using curl

**URL:** <https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184>\
**Category:** Elasticsearch\
**Created:** [January 29, 2023, 7:49pm UTC](https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184 "2023-01-29T19:49:05Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![sphawk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sphawk/32/76990_2.png) [@sphawk](https://discuss.elastic.co/u/sphawk)\
**Post date:** [January 29, 2023, 7:49pm UTC](https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184/1 "2023-01-29T19:49:05Z")

</div>

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:

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

```

return

```auto
{
  "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

```auto
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

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

```

or

```auto
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?

---

<div class="post-metadata">

**Author:** ![stephenb](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/stephenb/32/40856_2.png) [@stephenb](https://discuss.elastic.co/u/stephenb)\
**Post date:** [January 29, 2023, 8:53pm UTC](https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184/2 "2023-01-29T20:53:43Z")

</div>

Hi @sphawk

If you look on [this](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html) page...

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

```

Or You could use

`_source_excludes`  
Or  
`_source_includes`

---

<div class="post-metadata">

**Author:** ![sphawk](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/sphawk/32/76990_2.png) [@sphawk](https://discuss.elastic.co/u/sphawk)\
**Post date:** [January 30, 2023, 9:36am UTC](https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184/3 "2023-01-30T09:36:21Z")

</div>

great!

```auto
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

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [February 27, 2023, 9:36am UTC](https://discuss.elastic.co/t/get-just-some-fields-of-all-elements-using-curl/324184/4 "2023-02-27T09:36:56Z")

</div>

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