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

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","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.
For more options, visit https://groups.google.com/groups/opt_out.

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

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: http://www.elasticsearch.org/guide/reference/mapping/all-field.html

You can also disable indexing for this field. See : index: no in http://www.elasticsearch.org/guide/reference/mapping/core-types.html

Also, you can use multi match to search on fields you want: http://www.elasticsearch.org/guide/reference/query-dsl/multi-match-query.html

HTH

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet | @elasticsearchfr | @scrutmydocs

Le 13 mars 2013 à 15:04, srikanth gone 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","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.
For more options, visit 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.
For more options, visit https://groups.google.com/groups/opt_out.