# Search problem with restapi?

**URL:** <https://discuss.elastic.co/t/search-problem-with-restapi/2956>\
**Category:** Elasticsearch\
**Created:** [May 18, 2010, 2:29am UTC](https://discuss.elastic.co/t/search-problem-with-restapi/2956 "2010-05-18T02:29:24Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![1112](https://avatars.discourse-cdn.com/v4/letter/1/ba8739/32.png) [@1112](https://discuss.elastic.co/u/1112)\
**Post date:** [May 18, 2010, 2:29am UTC](https://discuss.elastic.co/t/search-problem-with-restapi/2956/1 "2010-05-18T02:29:24Z")

</div>

curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '  
{  
"tweet" : {  
"user" : "arden",  
"sortid": "2",  
"postDate" : "2009-11-15T14:12:12",  
"message" : "trying out Elastic Search"  
}  
}'

curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '  
{  
"tweet" : {  
"user" : "arden",  
"sortid": "1",  
"postDate" : "2009-11-15T14:12:12",  
"message" : "trying out Elastic Search"  
}  
}'

curl -XGET '[http://localhost:9200/twitter/tweet/\_search?q=+user:tujiao](http://localhost:9200/twitter/tweet/_search?q=+user:tujiao)  
+sortid:2&default\_operator=AND&fields=user,sortid'

but the search results are:

{"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":  
2,"hits":[{"\_index":"twitter","\_type":"tweet","\_id":"5"},  
{"\_index":"twitter","\_type":"tweet","\_id":"9"}]}}

that the user,sortid fields not in search results?

---

<div class="post-metadata">

**Author:** ![kimchy](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kimchy/32/44952_2.png) [@kimchy](https://discuss.elastic.co/u/kimchy)\
**Post date:** [May 18, 2010, 2:59am UTC](https://discuss.elastic.co/t/search-problem-with-restapi/2956/2 "2010-05-18T02:59:42Z")

</div>

Not sure I understand the example. You index two documents with id 1, and  
you run a query and get back ids 5 and 9? Have they been indexed with the  
proper data? Also, are you by any change disabling \_source in the mapping?

-shay.banon

On Tue, May 18, 2010 at 5:29 AM, 曹江华 [tujiao.com@gmail.com](mailto:tujiao.com@gmail.com) wrote:

> curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '  
> {  
> "tweet" : {  
> "user" : "arden",  
> "sortid": "2",  
> "postDate" : "2009-11-15T14:12:12",  
> "message" : "trying out Elastic Search"  
> }  
> }'
> 
> curl -XPUT '[http://localhost:9200/twitter/tweet/1](http://localhost:9200/twitter/tweet/1)' -d '  
> {  
> "tweet" : {  
> "user" : "arden",  
> "sortid": "1",  
> "postDate" : "2009-11-15T14:12:12",  
> "message" : "trying out Elastic Search"  
> }  
> }'
> 
> curl -XGET '[http://localhost:9200/twitter/tweet/\_search?q=+user:tujiao](http://localhost:9200/twitter/tweet/_search?q=+user:tujiao)  
> +sortid:2&default\_operator=AND&fields=user,sortid'
> 
> but the search results are:
> 
> {"\_shards":{"total":5,"successful":5,"failed":0},"hits":{"total":  
> 2,"hits":[{"\_index":"twitter","\_type":"tweet","\_id":"5"},  
> {"\_index":"twitter","\_type":"tweet","\_id":"9"}]}}
> 
> that the user,sortid fields not in search results?

---

<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, 4:24am UTC](https://discuss.elastic.co/t/search-problem-with-restapi/2956/3 "2017-07-06T04:24:01Z")

</div>


