# Getting complete value from ElasticSearch query

**URL:** <https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236>\
**Category:** Elasticsearch\
**Created:** [June 20, 2014, 6:52pm UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236 "2014-06-20T18:52:49Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Vinay\_Pandey](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@Vinay\_Pandey](https://discuss.elastic.co/u/Vinay_Pandey)\
**Post date:** [June 20, 2014, 6:52pm UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236/1 "2014-06-20T18:52:49Z")

</div>

I have the following structure on my ElasticSearch:

```
{
    _index: 3_exposureindex
    _type: exposuresearch
    _id: 12738
    _version: 4
    _score: 1
    _source: {
        Name: test2_update
        Description:
        CreateUserId: 8
        SourceId: null
        Id: 12738
        ExposureId: 12738
        CreateDate: 2014-06-20T16:18:50.500
        UpdateDate: 2014-06-20T16:19:57.547
        UpdateUserId: 8
    }
    fields: {
        _parent: 1
    }
}

```

I am trying to get both, the data in `_source` as well as that in `fields`,  
when I run the query:

```
{
  "query": {
    "terms": {
      "Id": [
        "12738"
      ]
    }
  }
}

```

All I get are the values contained in `_source`, whereas, if I run the  
query:

```
{
  "fields": [
    "_parent"
  ],
  "query": {
    "terms": {
      "Id": [
        "12738"
      ]
    }
  }
}

```

Then I only the `fields`. Is there a way to get both? I will be grateful  
for any help.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/cdb02319-f6ee-455e-bf13-762df7e33a82%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/cdb02319-f6ee-455e-bf13-762df7e33a82%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vinay\_Pandey](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@Vinay\_Pandey](https://discuss.elastic.co/u/Vinay_Pandey)\
**Post date:** [June 20, 2014, 6:54pm UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236/2 "2014-06-20T18:54:53Z")

</div>

I forgot to mention that I have asked the same question in StackOverflow  
[http://stackoverflow.com/questions/24333655/getting-complete-value-from-elasticsearch-query](http://stackoverflow.com/questions/24333655/getting-complete-value-from-elasticsearch-query)

On Friday, June 20, 2014 11:52:49 AM UTC-7, Vinay Pandey wrote:

> I have the following structure on my Elasticsearch:
> 
> ```
> {
> _index: 3_exposureindex
> _type: exposuresearch
> _id: 12738
> _version: 4
> _score: 1
> _source: {
> Name: test2_update
> Description:
> CreateUserId: 8
> SourceId: null
> Id: 12738
> ExposureId: 12738
> CreateDate: 2014-06-20T16:18:50.500
> UpdateDate: 2014-06-20T16:19:57.547
> UpdateUserId: 8
> }
> fields: {
> _parent: 1
> }
> }
> 
> ```
> 
> I am trying to get both, the data in `_source` as well as that in  
> `fields`, when I run the query:
> 
> ```
> {
> "query": {
> "terms": {
> "Id": [
> "12738"
> ]
> }
> }
> }
> 
> ```
> 
> All I get are the values contained in `_source`, whereas, if I run the  
> query:
> 
> ```
> {
> "fields": [
> "_parent"
> ],
> "query": {
> "terms": {
> "Id": [
> "12738"
> ]
> }
> }
> }
> 
> ```
> 
> Then I only the `fields`. Is there a way to get both? I will be grateful  
> for any help.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/f70efa60-f62c-4dc0-9812-e02a3a900ea4%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f70efa60-f62c-4dc0-9812-e02a3a900ea4%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Vinay\_Pandey](https://avatars.discourse-cdn.com/v4/letter/v/ebca7d/32.png) [@Vinay\_Pandey](https://discuss.elastic.co/u/Vinay_Pandey)\
**Post date:** [June 20, 2014, 7:31pm UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236/3 "2014-06-20T19:31:52Z")

</div>

This just got answered:

You should be able to specify "\_source" in the "fields"

Example:

{  
"fields": [  
"\_parent",  
"\_source"  
],  
"query": {  
"terms": {  
"Id": [  
"12738"  
]  
}  
}}

On Friday, June 20, 2014 11:52:49 AM UTC-7, Vinay Pandey wrote:

> I have the following structure on my Elasticsearch:
> 
> ```
> {
> _index: 3_exposureindex
> _type: exposuresearch
> _id: 12738
> _version: 4
> _score: 1
> _source: {
> Name: test2_update
> Description:
> CreateUserId: 8
> SourceId: null
> Id: 12738
> ExposureId: 12738
> CreateDate: 2014-06-20T16:18:50.500
> UpdateDate: 2014-06-20T16:19:57.547
> UpdateUserId: 8
> }
> fields: {
> _parent: 1
> }
> }
> 
> ```
> 
> I am trying to get both, the data in `_source` as well as that in  
> `fields`, when I run the query:
> 
> ```
> {
> "query": {
> "terms": {
> "Id": [
> "12738"
> ]
> }
> }
> }
> 
> ```
> 
> All I get are the values contained in `_source`, whereas, if I run the  
> query:
> 
> ```
> {
> "fields": [
> "_parent"
> ],
> "query": {
> "terms": {
> "Id": [
> "12738"
> ]
> }
> }
> }
> 
> ```
> 
> Then I only the `fields`. Is there a way to get both? I will be grateful  
> for any help.

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/00e590cf-352d-4ebf-800d-113565ee7fbe%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/00e590cf-352d-4ebf-800d-113565ee7fbe%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![brian\_yoder](https://avatars.discourse-cdn.com/v4/letter/b/f1d935/32.png) [@brian\_yoder](https://discuss.elastic.co/u/brian_yoder)\
**Post date:** [June 23, 2014, 7:07pm UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236/4 "2014-06-23T19:07:50Z")

</div>

Vinay,

To be more specific:

If you don't ask for any fields, then \_source is returned by default.

But if you ask for any fields at all, then \_source is not included by  
default. Therefore, if you wish to include \_source along with other fields,  
you must explicitly ask for \_source along with those other fields.

Brian

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/b6907975-ce05-4a9a-88cc-cf234e0c1990%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b6907975-ce05-4a9a-88cc-cf234e0c1990%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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 6, 2017, 1:20am UTC](https://discuss.elastic.co/t/getting-complete-value-from-elasticsearch-query/18236/5 "2017-07-06T01:20:29Z")

</div>


