# Elastic Search (Query)

**URL:** <https://discuss.elastic.co/t/elastic-search-query/5972>\
**Category:** Elasticsearch\
**Created:** [November 25, 2011, 11:21am UTC](https://discuss.elastic.co/t/elastic-search-query/5972 "2011-11-25T11:21:41Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![sweta\_k](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@sweta\_k](https://discuss.elastic.co/u/sweta_k)\
**Post date:** [November 25, 2011, 11:21am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/1 "2011-11-25T11:21:41Z")

</div>

What is the Query to Search a String in Elastic search , When i  
disable \_all and \_source Properties .

---

<div class="post-metadata">

**Author:** ![Karussell1](https://avatars.discourse-cdn.com/v4/letter/k/50afbb/32.png) [@Karussell1](https://discuss.elastic.co/u/Karussell1)\
**Post date:** [November 25, 2011, 11:39pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/2 "2011-11-25T23:39:09Z")

</div>

E.g. use the text query and specify the field (here 'description')

curl -XPOST [http://localhost:9200/](http://localhost:9200/) -d '{  
"query": {  
"text" : { "description" : "Some query here" }  
}}'

Regards,  
Peter.

On 25 Nov., 12:21, sweta k [shwete...@gmail.com](mailto:shwete...@gmail.com) wrote:

> What is the Query to Search a String in Elastic search , When i  
> disable \_all and \_source Properties .

---

<div class="post-metadata">

**Author:** ![sweta\_k](https://avatars.discourse-cdn.com/v4/letter/s/b19c9b/32.png) [@sweta\_k](https://discuss.elastic.co/u/sweta_k)\
**Post date:** [November 29, 2011, 6:07am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/3 "2011-11-29T06:07:13Z")

</div>

I unable to Search the String ,  
This is my Mapping:  
curl -XPUT localhost:9200/smit/default\_map/\_mapping -d '  
{  
"default\_map": {  
"\_all": {"enabled": false},  
"\_source" : {"enabled" : false},  
"properties": {  
"text": {  
"type": "string",  
"fields": {  
"text": {  
"store": "yes"}}}  
}  
}  
}'

Now Wen I search I m Unable to Get the String ... , For this Mapping i  
Shld be Able To Search the String As i Have Given "Store= yes" ...

On Nov 26, 4:39 am, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:

> E.g. use the text query and specify the field (here 'description')
> 
> curl -XPOSThttp://localhost:9200/-d '{  
> "query": {  
> "text" : { "description" : "Some query here" }
> 
> }}'
> 
> Regards,  
> Peter.
> 
> On 25 Nov., 12:21, sweta k [shwete...@gmail.com](mailto:shwete...@gmail.com) wrote:
> 
> > What is the Query to Search a String in Elastic search , When i  
> > disable \_all and \_source Properties .

---

<div class="post-metadata">

**Author:** ![Kartavya](https://avatars.discourse-cdn.com/v4/letter/k/65b543/32.png) [@Kartavya](https://discuss.elastic.co/u/Kartavya)\
**Post date:** [November 29, 2011, 6:14am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/4 "2011-11-29T06:14:53Z")

</div>

try to get actual mapping using

curl -XGET 'localh0st:9200/smit/default\_map/\_mapping'

Regards,  
Pulkit Agrawal

On Tue, Nov 29, 2011 at 11:37 AM, sweta k [shwetest1@gmail.com](mailto:shwetest1@gmail.com) wrote:

> I unable to Search the String ,  
> This is my Mapping:  
> curl -XPUT localhost:9200/smit/default\_map/\_mapping -d '  
> {  
> "default\_map": {  
> "\_all": {"enabled": false},  
> "\_source" : {"enabled" : false},  
> "properties": {  
> "text": {  
> "type": "string",  
> "fields": {  
> "text": {  
> "store": "yes"}}}  
> }  
> }  
> }'
> 
> Now Wen I search I m Unable to Get the String ... , For this Mapping i  
> Shld be Able To Search the String As i Have Given "Store= yes" ...
> 
> On Nov 26, 4:39 am, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> 
> > E.g. use the text query and specify the field (here 'description')
> > 
> > curl -XPOSThttp://localhost:9200/-d '{  
> > "query": {  
> > "text" : { "description" : "Some query here" }
> > 
> > }}'
> > 
> > Regards,  
> > Peter.
> > 
> > On 25 Nov., 12:21, sweta k [shwete...@gmail.com](mailto:shwete...@gmail.com) wrote:
> > 
> > > What is the Query to Search a String in Elastic search , When i  
> > > disable \_all and \_source Properties .

---

<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:** [November 29, 2011, 8:08am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/5 "2011-11-29T08:08:20Z")

</div>

What is your search request? Note, you need to specify a default field to  
search against if you disable \_all.

On Tue, Nov 29, 2011 at 8:07 AM, sweta k [shwetest1@gmail.com](mailto:shwetest1@gmail.com) wrote:

> I unable to Search the String ,  
> This is my Mapping:  
> curl -XPUT localhost:9200/smit/default\_map/\_mapping -d '  
> {  
> "default\_map": {  
> "\_all": {"enabled": false},  
> "\_source" : {"enabled" : false},  
> "properties": {  
> "text": {  
> "type": "string",  
> "fields": {  
> "text": {  
> "store": "yes"}}}  
> }  
> }  
> }'
> 
> Now Wen I search I m Unable to Get the String ... , For this Mapping i  
> Shld be Able To Search the String As i Have Given "Store= yes" ...
> 
> On Nov 26, 4:39 am, Karussell [tableyourt...@googlemail.com](mailto:tableyourt...@googlemail.com) wrote:
> 
> > E.g. use the text query and specify the field (here 'description')
> > 
> > curl -XPOSThttp://localhost:9200/-d '{  
> > "query": {  
> > "text" : { "description" : "Some query here" }
> > 
> > }}'
> > 
> > Regards,  
> > Peter.
> > 
> > On 25 Nov., 12:21, sweta k [shwete...@gmail.com](mailto:shwete...@gmail.com) wrote:
> > 
> > > What is the Query to Search a String in Elastic search , When i  
> > > disable \_all and \_source Properties .

---

<div class="post-metadata">

**Author:** ![arta](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@arta](https://discuss.elastic.co/u/arta)\
**Post date:** [December 19, 2011, 11:58pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/6 "2011-12-19T23:58:41Z")

</div>

> Note, you need to specify a default field to search against if you disable \_all.

I'm having the same problem. After I disabled \_all, search queries returns 0 hits, except for match\_all query.

Here's my mapping:  
curl -XGET '[http://localhost:9200/topic1/\_mapping](http://localhost:9200/topic1/_mapping)'

{  
"topic1":{  
"DefaultType":{  
"\_source":{"compress":true},  
"properties":{  
"content":{"type":"string"},  
"time\_modified":{"format":"dateOptionalTime","type":"date"}  
},  
"\_all":{"enabled":false}  
}  
}  
}

Any query like this does not hit:

curl -XGET '[http://localhost:9200/topic1/\_search](http://localhost:9200/topic1/_search)'  
-d '{ "query" : { "wildcard" : { "default\_field" : "content", "query" : "\*" }}}'

{  
"took":2,  
"timed\_out":false,  
"\_shards":{"total":5,"successful":5,"failed":0},  
"hits":{"total":0,"max\_score":null,"hits":}  
}

Except for match\_all. this hits:

curl -XGET '[http://localhost:9200/topic1/\_search?size=1](http://localhost:9200/topic1/_search?size=1)' -d '{ "query" : { "match\_all" : { }}}'

{ some result }

Thanks for your help.

---

<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:** [December 20, 2011, 3:04pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/7 "2011-12-20T15:04:32Z")

</div>

Can you gist a full recreation? See [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/help).

On Tue, Dec 20, 2011 at 1:58 AM, arta [artasano@sbcglobal.net](mailto:artasano@sbcglobal.net) wrote:

> > Note, you need to specify a default field to search against if you  
> > disable  
> > \_all.
> 
> I'm having the same problem. After I disabled \_all, search queries returns  
> 0  
> hits, except for match\_all query.
> 
> Here's my mapping:  
> curl -XGET '[http://localhost:9200/topic1/\_mapping](http://localhost:9200/topic1/_mapping)'
> 
> {  
> "topic1":{  
> "DefaultType":{  
> "\_source":{"compress":true},  
> "properties":{  
> "content":{"type":"string"},  
> "time\_modified":{"format":"dateOptionalTime","type":"date"}  
> },  
> "\_all":{"enabled":false}  
> }  
> }  
> }
> 
> Any query like this does not hit:
> 
> curl -XGET '[http://localhost:9200/topic1/\_search](http://localhost:9200/topic1/_search)'  
> -d '{ "query" : { "wildcard" : { "default\_field" : "content", "query" :  
> "\*"  
> }}}'
> 
> {  
> "took":2,  
> "timed\_out":false,  
> "\_shards":{"total":5,"successful":5,"failed":0},  
> "hits":{"total":0,"max\_score":null,"hits":}  
> }
> 
> Except for match\_all. this hits:
> 
> curl -XGET '[http://localhost:9200/topic1/\_search?size=1](http://localhost:9200/topic1/_search?size=1)' -d '{ "query" : {  
> "match\_all" : { }}}'
> 
> { some result }
> 
> Thanks for your help.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3599932.html](http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3599932.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![arta](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@arta](https://discuss.elastic.co/u/arta)\
**Post date:** [December 20, 2011, 5:39pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/8 "2011-12-20T17:39:34Z")

</div>

Thanks, Shay.  
It is gist: 1502438.

---

<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:** [December 20, 2011, 6:00pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/9 "2011-12-20T18:00:00Z")

</div>

I added a comment there. You use `term` query that does not really use  
`default_field`.

On Tue, Dec 20, 2011 at 7:39 PM, arta [artasano@sbcglobal.net](mailto:artasano@sbcglobal.net) wrote:

> Thanks, Shay.  
> It is gist: 1502438.
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3601831.html](http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3601831.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![arta](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@arta](https://discuss.elastic.co/u/arta)\
**Post date:** [December 20, 2011, 8:16pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/10 "2011-12-20T20:16:57Z")

</div>

Follow up:  
Seems like "default\_field" does not work with most of queries regardless \_all is disabled or not.  
Hope this helps.

---

<div class="post-metadata">

**Author:** ![arta](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@arta](https://discuss.elastic.co/u/arta)\
**Post date:** [December 20, 2011, 8:18pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/11 "2011-12-20T20:18:10Z")

</div>

> You use `term` query that does not really use `default_field`.

Then how can I search when \_all is disabled?

---

<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:** [December 21, 2011, 3:39am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/12 "2011-12-21T03:39:50Z")

</div>

default\_field applies only for the query\_string query, all the other  
queries simply require you to specify the field to search on (like term  
query).

On Tue, Dec 20, 2011 at 10:18 PM, arta [artasano@sbcglobal.net](mailto:artasano@sbcglobal.net) wrote:

> > You use `term` query that does not really use `default_field`.
> 
> Then how can I search when \_all is disabled?
> 
> --  
> View this message in context:  
> [http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3602200.html](http://elasticsearch-users.115913.n3.nabble.com/Elastic-Search-Query-tp3535843p3602200.html)  
> Sent from the Elasticsearch Users mailing list archive at [Nabble.com](http://Nabble.com).

---

<div class="post-metadata">

**Author:** ![arta](https://avatars.discourse-cdn.com/v4/letter/a/aca169/32.png) [@arta](https://discuss.elastic.co/u/arta)\
**Post date:** [December 21, 2011, 5:32pm UTC](https://discuss.elastic.co/t/elastic-search-query/5972/13 "2011-12-21T17:32:46Z")

</div>

I see now. Thank you so much for clearing it out.  
It turned out I did wrong at the first place when I tried to disable \_all. I used Java API and mistakingly did like this:  
client.admin().indices().preparePutMapping("index1").setType("type1").setSource("{"\_all": {"enabled": false }}").execute()  
I thought I didn't need to give the type name again in the source because it was given to setType(). But it was not correct. (right?)  
Because of this mistake, I was not able to hit any query, so I came to this page and saw your response mentioning about 'default field'.  
Anyway, the problem solved.  
Thanks again.

---

<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, 3:44am UTC](https://discuss.elastic.co/t/elastic-search-query/5972/14 "2017-07-06T03:44:41Z")

</div>


