# How to search data inside \_source

**URL:** <https://discuss.elastic.co/t/how-to-search-data-inside--source/16146>\
**Category:** Elasticsearch\
**Created:** [March 4, 2014, 2:51pm UTC](https://discuss.elastic.co/t/how-to-search-data-inside--source/16146 "2014-03-04T14:51:21Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bhupali\_Kalmegh](https://avatars.discourse-cdn.com/v4/letter/b/4bbf92/32.png) [@Bhupali\_Kalmegh](https://discuss.elastic.co/u/Bhupali_Kalmegh)\
**Post date:** [March 4, 2014, 2:51pm UTC](https://discuss.elastic.co/t/how-to-search-data-inside--source/16146/1 "2014-03-04T14:51:21Z")

</div>

\*Tweet Index definition : \*

"tweet": {

```
    "tweet": {

        "index": {

            "number_of_shards": 2,

            "number_of_replicas": 1

        }

    },

    "mappings": {

        "blog": {

            "_all": {

                "enabled": False

            },

            "dynamic": False

        }

    }

}

```

_Tweet data insertion :_

curl -XPOST "[http://localhost:9200/tweet/blog/](http://localhost:9200/tweet/blog/)" -d'

{

```
"id" : "ID1",

"user" : "User1",

"title" : "tweet1"

```

}'

curl -XPOST "[http://localhost:9200/tweet/blog/](http://localhost:9200/tweet/blog/)" -d'

{

```
"id" : "ID2",

"user" : "User2",

"title" : "tweet2"

```

}'

_Read all data :_

curl -XGET "[http://localhost:9200/tweet/blog/\_search](http://localhost:9200/tweet/blog/_search)"

{

```
took: 1

timed_out: false

_shards: {

    total: 2

    successful: 2

    failed: 0

}

hits: {

    total: 2

    max_score: 1

    hits: [

        {

            _index: tweet

            _type: blog

            _id: 1

            _score: 1

            _source: {

                    id : ID1,

                    user : User1,

                    title : tweet1

            }

        },

        {

            _index: tweet

            _type: blog

            _id: 2

            _score: 1

            _source: {

                    id : ID2,

                    user : User2,

                    title : tweet2

            }

        }

```

}

_Now I wish to fetch the document for User2_

Based on Link 1 and 2, I have tried the following ways, however all in  
vein –

_Option 1:_

curl -XPOST "[http://localhost:9200/tweet/blog/\_search](http://localhost:9200/tweet/blog/_search)" -d'

{

```
"query" : {

    "term" : { "user" : "User2" }

}

```

}'

_Option 2:_

```
 curl -XGET "http://localhost:9200/tweet/blog/_search?q=user:User2"

```

_Option 3:_

```
 curl -XGET "http://localhost:9200/tweet/blog/_search?source={user:User2}"

```

_Option 4:_

```
 curl -XGET "http://localhost:9200/tweet/blog/_search?_source={‘user’:’User2’}"

```

Link 1:

> **[Open Knowledge Labs](http://okfnlabs.org/blog/2013/07/01/elasticsearch-query-tutorial.html#basic-queries-using-only-the-query-string)**
>
> We're a community of civic hackers, data wranglers and ordinary citizens intrigued and excited by the possibilities of combining technology and information for good – making government more accountable, culture more accessible and science more...

Link 2:  
[http://blog.florian-hopf.de/2013/08/getting-started-with-elasticsearch-part.html](http://blog.florian-hopf.de/2013/08/getting-started-with-elasticsearch-part.html)

Do you recommend a suitable solution to this problem?

--  
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/7ffecb9a-14f9-4cbe-beef-8227937f4168%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/7ffecb9a-14f9-4cbe-beef-8227937f4168%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly\_2](https://avatars.discourse-cdn.com/v4/letter/b/d07c76/32.png) [@Binh\_Ly\_2](https://discuss.elastic.co/u/Binh_Ly_2)\
**Post date:** [March 4, 2014, 10:59pm UTC](https://discuss.elastic.co/t/how-to-search-data-inside--source/16146/2 "2014-03-04T22:59:13Z")

</div>

You'd have to turn dynamic back to true. Dynamic = false means ignore the  
"new" field and don't index it. If a field is not indexed, then you cannot  
search for it.

--  
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/f0b13a04-c827-4652-9772-9a3516bf064c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/f0b13a04-c827-4652-9772-9a3516bf064c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:45am UTC](https://discuss.elastic.co/t/how-to-search-data-inside--source/16146/3 "2017-07-06T01:45:44Z")

</div>


