# How to skip some fields in elastic search using queryString method()

**URL:** https://discuss.elastic.co/t/how-to-skip-some-fields-in-elastic-search-using-querystring-method/11137
**Category:** Elasticsearch
**Created:** [March 13, 2013, 2:04pm UTC](https://discuss.elastic.co/t/how-to-skip-some-fields-in-elastic-search-using-querystring-method/11137 "2013-03-13T14:04:07Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Srikanth\_gone](https://avatars.discourse-cdn.com/v4/letter/s/a3d4f5/32.png) [@Srikanth\_gone](https://discuss.elastic.co/u/Srikanth_gone)
#### Post date: [March 13, 2013, 2:04pm UTC](https://discuss.elastic.co/t/how-to-skip-some-fields-in-elastic-search-using-querystring-method/11137/1 "2013-03-13T14:04:07Z")

</div>

Hi All,

i have used queryString() method to search data..

this is my code..

response =  
client.prepareSearch().setQuery(QueryBuilders.queryString("_"+searchText+"_")).setIndices("dc\_user\_idx").setExplain(true)  
.setTypes("DC\_USER","DC\_ROLE").execute().actionGet();

output is:

{  
"took" : 1188,  
"timed\_out" : false,  
"\_shards" : {  
"total" : 5,  
"successful" : 5,  
"failed" : 0  
},  
"hits" : {  
"total" : 1,  
"max\_score" : 1.0,  
"hits" : [ {  
"\_index" : "dc\_user\_idx",  
"\_type" : "DC\_USER",  
"\_id" : "4650aad2-a6be-4d89-9e0d-99aa05cccd5e",  
"\_score" : 1.0, "\_source" : {"\_id":"4650aad2-a6be-4d89-9e0d-99aa05cccd5e","\_class":"com.newwave.dc.user.model.User","enabled":"true","userName":"SampleUser","password":"SampleUser","firstName":"SampleUser","displayName":"SampleUser [SampleUser","lastName":"SampleUser","email":"SampleUser@gmail.com](mailto:SampleUser%22,%22lastName%22:%22SampleUser%22,%22email%22:%22SampleUser@gmail.com)","userTypeId":"5e4d68cf-e39a-4775-a128-99ed88d6ede5","userStatusId":"67cb3fea-53ee-47f9-b3dc-c319565207ad","role":[{"role":"{ "$ref" : "DC\_ROLE", "$id" : "25554db2-9942-4790-b28e-4ea5f95f9a26" }"},{"role":"{ "$ref" : "DC\_ROLE", "$id" : "cb58a018-777d-4e91-8f7f-7e8d7bf5a5c3" }"}],"createdBy":"admin","createdOn":"2013-03-12T09:53:33.000Z","modifiedBy":"admin","modifiedOn":"2013-03-12T09:53:54.000Z","additionalFields":{"sdfsdfsd":"fsdf"},"office":{"name":"SampleUser","address1":"SampleUser","address2":"SampleUser","city":"SampleUser","state":"c6ebfc08-a9b3-489c-bad6-f519a4c23d1c","zipcode":"1554","phone":"54545"},"practice":{"name":"","address1":"","address2":"","city":"","state":"","zipcode":"","phone":""}}  
} ]  
}  
}

my problem is.. it is searching All fields default if i want to skip "\_class" field.. how to skip fields through java

please help me.

--  
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).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

### Author: ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)
#### Post date: [March 13, 2013, 2:18pm UTC](https://discuss.elastic.co/t/how-to-skip-some-fields-in-elastic-search-using-querystring-method/11137/2 "2013-03-13T14:18:09Z")

</div>

I would say: if you don't want to search in it, don't index it! 😉

You should know that when searching with query string, you search in \_all field.  
You can define your own mapping for your type and tell that for the field \_class: include\_in\_all : false

See: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/all-field.html)

You can also disable indexing for this field. See : index: no in [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/mapping/core-types.html)

Also, you can use multi match to search on fields you want: [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html)

HTH

--  
David Pilato | Technical Advocate | [Elasticsearch.com](http://Elasticsearch.com)  
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 13 mars 2013 à 15:04, srikanth gone [srikanthg93@gmail.com](mailto:srikanthg93@gmail.com) a écrit :

> Hi All,
> 
> i have used queryString() method to search data..
> 
> this is my code..
> 
> response = client.prepareSearch().setQuery(QueryBuilders.queryString("_"+searchText+"_")).setIndices("dc\_user\_idx").setExplain(true)  
> .setTypes("DC\_USER","DC\_ROLE").execute().actionGet();
> 
> output is:
> 
> {  
> "took" : 1188,  
> "timed\_out" : false,  
> "\_shards" : {  
> "total" : 5,  
> "successful" : 5,  
> "failed" : 0  
> },  
> "hits" : {  
> "total" : 1,  
> "max\_score" : 1.0,  
> "hits" : [ {  
> "\_index" : "dc\_user\_idx",  
> "\_type" : "DC\_USER",  
> "\_id" : "4650aad2-a6be-4d89-9e0d-99aa05cccd5e",  
> "\_score" : 1.0, "\_source" : {"\_id":"4650aad2-a6be-4d89-9e0d-99aa05cccd5e","\_class":"com.newwave.dc.user.model.User","enabled":"true","userName":"SampleUser","password":"SampleUser","firstName":"SampleUser","displayName":"SampleUser [SampleUser","lastName":"SampleUser","email":"SampleUser@gmail.com](mailto:SampleUser%22,%22lastName%22:%22SampleUser%22,%22email%22:%22SampleUser@gmail.com)","userTypeId":"5e4d68cf-e39a-4775-a128-99ed88d6ede5","userStatusId":"67cb3fea-53ee-47f9-b3dc-c319565207ad","role":[{"role":"{ "$ref" : "DC\_ROLE", "$id" : "25554db2-9942-4790-b28e-4ea5f95f9a26" }"},{"role":"{ "$ref" : "DC\_ROLE", "$id" : "cb58a018-777d-4e91-8f7f-7e8d7bf5a5c3" }"}],"createdBy":"admin","createdOn":"2013-03-12T09:53:33.000Z","modifiedBy":"admin","modifiedOn":"2013-03-12T09:53:54.000Z","additionalFields":{"sdfsdfsd":"fsdf"},"office":{"name":"SampleUser","address1":"SampleUser","address2":"SampleUser","city":"SampleUser","state":"c6ebfc08-a9b3-489c-bad6-f519a4c23d1c","zipcode":"1554","phone":"54545"},"practice":{"name":"","address1":"","address2":"","city":"","state":"","zipcode":"","phone":""}}  
> } ]  
> }  
> }
> 
> my problem is.. it is searching All fields default if i want to skip "\_class" field.. how to skip fields through java
> 
> please help me.
> 
> --  
> 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).  
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
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).  
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, 2:46am UTC](https://discuss.elastic.co/t/how-to-skip-some-fields-in-elastic-search-using-querystring-method/11137/3 "2017-07-06T02:46:40Z")

</div>


