# Basic elasticsearch querying

**URL:** <https://discuss.elastic.co/t/basic-elasticsearch-querying/26816>\
**Category:** Elasticsearch\
**Created:** [August 4, 2015, 4:16pm UTC](https://discuss.elastic.co/t/basic-elasticsearch-querying/26816 "2015-08-04T16:16:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bluethundr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluethundr/32/409_2.png) [@bluethundr](https://discuss.elastic.co/u/bluethundr)\
**Post date:** [August 4, 2015, 4:16pm UTC](https://discuss.elastic.co/t/basic-elasticsearch-querying/26816/1 "2015-08-04T16:16:41Z")

</div>

Hey guys,

I need some help with a very basic elasticsearch query.

We have an index known as 'episodes' that has a list of tv shows in it.

```
root@aoaapld00135la ~]# curl http://localhost:9200/_cat/indices | grep episodes
  % Total % Received % Xferd Average Speed Time Time Time Current
                                 Dload Upload Total Spent Left Speed
100 1500 100 1500 0 0 23036 0 --:--:-- --:--:-- --:--:-- 25862
green open episodes 5 1 3 0 35.7kb 17.9kb

```

I can view the contents of the index using the 'search' parameter'

```
[root@aoaapld00135la ~]# curl http://localhost:9200/episodes/_search
{"took":3,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":3,"max_score":1.0,"hits":[{"_index":"episodes","_type":"episode","_id":"4","_score":1.0,"_source":{"id":4,"number":"0010","show_id":3,"title":"NBC Cancels Star Trek","air_date":"1977-07-04","season":"4","episode_type":"live","hosts":[{"id":7,"name":"Elliot Gould","distinguishing_info":null}],"musical_guests":[{"id":10,"name":"Sex Pistols","distinguishing_info":null}],"episode_versions":[{"id":4,"video_url":"http://www.pivotal.io","episode_id":4,"air_date":"1977-07-04","episode_version_type_id":3,"repeat_text":"some data for SNL entered by pivotal","parent_episode_version_id":null,"episode_version_type":{"id":3,"show_id":3,"name":"Air"},"segments":[]}]}},{"_index":"episodes","_type":"episode","_id":"7","_score":1.0,"_source":{"id":7,"number":"0020","show_id":3,"title":"CF is delivered","air_date":null,"season":"","episode_type":"","hosts":[{"id":13,"name":"Chris Umbel","distinguishing_info":null},{"id":16,"name":"Shaozhen Ding","distinguishing_info":null}],"musical_guests":[{"id":19,"name":"GT","distinguishing_info":null}],"episode_versions":[{"id":7,"video_url":"http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v","episode_id":7,"air_date":"2015-06-05","episode_version_type_id":3,"repeat_text":"pivotal, GT, umbel, ding, JMX","parent_episode_version_id":null,"episode_version_type":{"id":3,"show_id":3,"name":"Air"},"segments":[{"id":4,"name":"New Segment","synopsis":"PBR\u0026B meditation scenester, freegan artisan Tumblr forage Kickstarter cliche paleo Portland post-ironic McSweeney's synth whatever. Lo-fi Truffaut crucifix vegan meditation, lomo ethical leggings.","tags":"","episode_version_id":7,"video_start_time":"00:02:22","video_end_time":"00:04:00","segment_type":"","production_number":"","tape_date":"2015-06-19","order":1,"live":false,"show_id":3,"duration":"","guests":[{"id":22,"name":"Tom Cruise","distinguishing_info":null}],"writers":[],"producers":[],"cast_credits":[]}]},{"id":10,"video_url":"http://download.blender.org/peach/bigbuckbunny_movies/BigBuckBunny_640x360.m4v","episode_id":7,"air_date":null,"episode_version_type_id":3,"repeat_text":"","parent_episode_version_id":7,"episode_version_type":{"id":3,"show_id":3,"name":"Air"},"segments":[]}]}},{"_index":"episodes","_type":"episode","_id":"3","_score":1.0,"_source":{"id":3,"number":"001","show_id":3,"title":"Episode One","air_date":"2015-06-01","season":"1","episode_type":"Live Taping","hosts":[{"id":3,"name":"Snoop Dogg","distinguishing_info":null}],"musical_guests":[{"id":6,"name":"John Legend","distinguishing_info":null}],"episode_versions":[{"id":3,"video_url":"","episode_id":3,"air_date":"2015-06-25","episode_version_type_id":3,"repeat_text":"","parent_episode_version_id":null,"episode_version_type":{"id":3,"show_id":3,"name":"Air"},"segments":[]}]}}]}}

```

So if I wanted to find the episode with the id of 19

```
{"id":19,"name":"GT","distinguishing_info":null}

```

How can I format this query? I tried going:

But all I got back was this instead of the info from the 'episode':

```
[root@aoaapld00135la ~]# curl http://localhost:9200/episodes/type/_search?q=id:16
{"took":2,"timed_out":false,"_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":0,"max_score":null,"hits":[]}}

```

Can you please let me know how to format this query?

Thanks

---

<div class="post-metadata">

**Author:** ![bluethundr](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bluethundr/32/409_2.png) [@bluethundr](https://discuss.elastic.co/u/bluethundr)\
**Post date:** [August 4, 2015, 7:42pm UTC](https://discuss.elastic.co/t/basic-elasticsearch-querying/26816/2 "2015-08-04T19:42:34Z")

</div>

Never mind, I think I got it:

```
#curl http://3.3.87.69:9200/episodes/_search?pretty -d '
{
  "query": { "match_all": {} },
  "_source": ["title","NBC Cancels Star Trek"]
}'

```

Gives me:

```
{
  "took" : 3,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "failed" : 0
  },
  "hits" : {
    "total" : 3,
    "max_score" : 1.0,
    "hits" : [ {
      "_index" : "episodes",
      "_type" : "episode",
      "_id" : "4",
      "_score" : 1.0,
      "_source":{"title":"NBC Cancels Star Trek"}
    }, {
      "_index" : "episodes",
      "_type" : "episode",
      "_id" : "7",
      "_score" : 1.0,
      "_source":{"title":"CF is delivered"}
    }, {
      "_index" : "episodes",
      "_type" : "episode",
      "_id" : "3",
      "_score" : 1.0,
      "_source":{"title":"Episode One"}
    } ]
  }
}

```

Thanks

---

<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:** [July 5, 2017, 11:57pm UTC](https://discuss.elastic.co/t/basic-elasticsearch-querying/26816/3 "2017-07-05T23:57:25Z")

</div>


