Want to search on multiple fields

I want to search on multiple fields,and using this ..but it reds only last
line so please suggest
how to search on multiple fields with java

                        SearchResponse response = 

client.prepareSearch("resume_index")

.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
//
.addScriptField("KeySkills","asp",QueryBuilders.prefixQuery("CurrentLocation","n",Map<"CurrentLocation","n">))

.setQuery(QueryBuilders.termQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
//
.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation", "d")))

.setQuery(QueryBuilders.prefixQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))

.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation","delhi")).must(termQuery("From","****r@gmail.com")))
.setFrom(0)
.setSize(5)
.setExplain(true)
.execute()
.actionGet();

--
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.

Have a look at: http://www.elasticsearch.org/guide/reference/java-api/query-dsl-queries.html

See Bool Queries.

Does it help?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 févr. 2013 à 08:15, MUKESH PANDEY mukeshp073@gmail.com a écrit :

I want to search on multiple fields,and using this ..but it reds only last line so please suggest
how to search on multiple fields with java

                        SearchResponse response = client.prepareSearch("resume_index")
                                 .setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
                                //   .addScriptField("KeySkills","asp",QueryBuilders.prefixQuery("CurrentLocation","n",Map<"CurrentLocation","n">))
                                    .setQuery(QueryBuilders.termQuery("Name", "Mahi Singh"))
                                    .setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
                                    // .setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation", "d")))
                                     .setQuery(QueryBuilders.prefixQuery("Name", "Mahi Singh"))
                                   .setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
                                   .setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation","delhi")).must(termQuery("From","****r@gmail.com")))
                                    .setFrom(0)
                                    .setSize(5)
                                    .setExplain(true)
                                    .execute()
                                    .actionGet();

--
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.

Thanks for reply sir,

            I have already tried  Bool Queries. likes this

.setQuery(QueryBuilders.boolQuery()
.must(termQuery("KeySkills","asp"))
.must(termQuery("CurrentLocation", "delhi"))
.must(termQuery("CTC", "1."))
.must(termQuery("TotalExperience", "1")))

      But i think Bool Query work always same type filed with multiple

times ......and My requirement is different fileds..I want to search with
more than one types filed..with java api.

On Sat, Feb 16, 2013 at 1:04 PM, David Pilato david@pilato.fr wrote:

Have a look at:
Elasticsearch Platform — Find real-time answers at scale | Elastic

See Bool Queries.

Does it help?

--
David :wink:
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

Le 16 févr. 2013 à 08:15, MUKESH PANDEY mukeshp073@gmail.com a écrit :

I want to search on multiple fields,and using this ..but it reds only
last line so please suggest
how to search on multiple fields with java

                        SearchResponse response =

client.prepareSearch("resume_index")

.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
//
.addScriptField("KeySkills","asp",QueryBuilders.prefixQuery("CurrentLocation","n",Map<"CurrentLocation","n">))

.setQuery(QueryBuilders.termQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
//
.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation", "d")))

.setQuery(QueryBuilders.prefixQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))

.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation","delhi")).must(termQuery("From","****
r@gmail.com")))
.setFrom(0)
.setSize(5)
.setExplain(true)
.execute()
.actionGet();

--
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.

--
mukeshp073@gmail.com
Laitkor.infosolution pvt ltd

--
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 recommend you to take a look at Match Query or Multi Match Query (for
multi fields)

this should be a good starter for what you want to do. Hope this helps

simon

On Saturday, February 16, 2013 8:15:31 AM UTC+1, MUKESH PANDEY wrote:

I want to search on multiple fields,and using this ..but it reds only
last line so please suggest
how to search on multiple fields with java

                        SearchResponse response = 

client.prepareSearch("resume_index")

.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
//
.addScriptField("KeySkills","asp",QueryBuilders.prefixQuery("CurrentLocation","n",Map<"CurrentLocation","n">))

.setQuery(QueryBuilders.termQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
//
.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation", "d")))

.setQuery(QueryBuilders.prefixQuery("Name", "Mahi Singh"))

.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))

.setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation","delhi")).must(termQuery("From","****
r...@gmail.com <javascript:>")))
.setFrom(0)
.setSize(5)
.setExplain(true)
.execute()
.actionGet();

--
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.

this is my Json:
"_type":"emls","_source":
{"ResumeHeadline":"System/Networkadmin with 3 yrs of Experience ",
"LastEmployer":" 3i Infotech consultancyservices ",
"Subject":"Fwd: Naukri.com - SA:- September 2012, Linux System Administrator - Salary Best in Industry - Project Assistant, Homi Bhabha Centre for Science & Education, TIFR Mankhurd, Mumbai., 3.0 yrs, Navi Mumbai",
"CurrentDesignation":null,
"Recommendations":" Not Mentioned ",
"LastDesignation":" Assistant Engineer ",
"CurrentLocation":" NaviMumbai, Maharashtra, INDIA ",
"Path":"E:\emls\output\laitkor@gmail.com.tarubairam_21.doc","TotalExperience":null,
"Name":null,"Lastmodifiedon":" 07-Feb-2013",
"Landline":"91-- ",

Now using this code for filter search is any thing wrong ?

XContentBuilder indexSettings = null;
Settings settings = ImmutableSettings.settingsBuilder().put("cluster.name", "elasticsearch").build();
Client client = new TransportClient(settings).addTransportAddress(new InetSocketTransportAddress("192.168.X.XX", 9300));
client.admin().indices().prepareRefresh("resume_index").execute().actionGet();
FilterBuilders.andFilter(
// FilterBuilders.prefixFilter("keyskil", "asp"),
FilterBuilders.prefixFilter("CurrentLocation", "delhi")
);
AndFilterBuilder queryFilters = FilterBuilders.andFilter();
// queryFilters.add(FilterBuilders.prefixFilter("keyskil", "asp"));
queryFilters.add(FilterBuilders.prefixFilter("CurrentLocation", "n"));

   FilterBuilder aggFilter = FilterBuilders.andFilter(queryFilters); 
  QueryBuilder queryBuilder = QueryBuilders.filteredQuery(QueryBuilders.prefixQuery("CurrentLocation", "d"),aggFilter); 
	
	SearchResponse response = client.prepareSearch("resume_index")
	                             .setSearchType(SearchType.QUERY_AND_FETCH) 
	                             .setQuery(queryBuilder) 
                                .setFilter(aggFilter) 
	                            
									//.setQuery(QueryBuilders.termQuery("Name", "Mahi Singh"))
									//.setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
                                  // .setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation", "delhi")))
                                    // .setQuery(QueryBuilders.prefixQuery("Name", "Mahi Singh"))
                                  // .setQuery(QueryBuilders.prefixQuery("CurrentLocation","d"))
                                  // .setQuery(QueryBuilders.boolQuery().must(termQuery("CurrentLocation","delhi")).must(termQuery("From","laitkor@gmail.com")))
									.setFrom(66)
									.setSize(100)
									.setExplain(true)
								
									.execute()
									.actionGet();
	
	
 	System.out.println(response.toString());

find result:

               {

"took" : 16,
"timed_out" : false,
"_shards" : {
"total" : 5,
"successful" : 5,
"failed" : 0
},
"hits" : {
"total" : 0,
"max_score" : null,
"hits" : [ ]
}
}