Search API help

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with *gmail.com and have firstname as
"abc"

email : "gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : xyz@gmail.com
firstname : xyz

email : abc@gmail.com
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as "gmail.com", thats ahy
i am using wildcard there.

Thanks in advanced.

Mohsin

--

Not sure to fully understand but did you try with must clauses instead of
should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen smhdiu@gmail.com a écrit :

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with *gmail.com and have firstname as
"abc"

email : "gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : xyz@gmail.com
firstname : xyz

email : abc@gmail.com
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as "gmail.com", thats ahy i
am using wildcard there.

Thanks in advanced.

Mohsin

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

abc@gmail.com
xyz@gmail.com

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(termQuery("firstName", criteria.getFirstName()));

Result

email : abc@gmail.com , Firstname : abc
email : xyz@gmail.com , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as abc
so it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning any
hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:

Not sure to fully understand but did you try with must clauses instead
of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen <smh...@gmail.com <javascript:>>
a écrit :

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with *gmail.com and have firstname
as "abc"

email : "gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : x...@gmail.com <javascript:>
firstname : xyz

email : a...@gmail.com <javascript:>
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as "gmail.com", thats
ahy i am using wildcard there.

Thanks in advanced.

Mohsin

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Have a look here: Test case for must clause · GitHub

It works fine for me.

David.

Le 27 novembre 2012 à 16:24, mohsin husen smhdiu@gmail.com a écrit :

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

abc@gmail.com
xyz@gmail.com

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(termQuery("firstName", criteria.getFirstName()));

Result

email : abc@gmail.com , Firstname : abc
email : xyz@gmail.com , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as abc so
it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning any
hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:

Not sure to fully understand but did you try with must clauses
instead of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen < smh...@gmail.com> a écrit :

> > >     I am searching using the JAVA API as follows :
Test case 1 : (it should return user with * gmail.com

http://gmail.com and have firstname as "abc"
=====================
email : " gmail.com http://gmail.com "
firstname : "abc"

boolQuery().should(wildcardQuery("email",

""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :
=============
email : x...@gmail.com
firstname : xyz

email : a...@gmail.com
firstname : abc


here i want only one result(2nd result) that is where both the field

is satisfied.
how to achieve that?

note that user can input in email partial values as " gmail.com

http://gmail.com ", thats ahy i am using wildcard there.

Thanks in advanced.

Mohsin



--

--
David Pilato
http://www.scrutmydocs.org/ http://www.scrutmydocs.org/
http://dev.david.pilato.fr/ http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

FYI, I created a full test case here:

HTH
David.

Le 27 novembre 2012 à 16:49, David Pilato david@pilato.fr a écrit :

Have a look here: Test case for must clause · GitHub

It works fine for me.

David.

Le 27 novembre 2012 à 16:24, mohsin husen smhdiu@gmail.com a écrit :

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

abc@gmail.com
xyz@gmail.com

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email",
""+criteria.getEmail()+""))
.should(termQuery("firstName", criteria.getFirstName()));

Result

email : abc@gmail.com , Firstname : abc
email : xyz@gmail.com , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as abc
so it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning any
hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:
> > > Not sure to fully understand but did you try with must clauses
> > > instead of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen < smh...@gmail.com> a écrit

:

 > > > >      I am searching using the JAVA API as follows :
 Test case 1 : (it should return user with * gmail.com

http://gmail.com and have firstname as "abc"
=====================
email : " gmail.com http://gmail.com "
firstname : "abc"

 boolQuery().should(wildcardQuery("email",

""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

 result :
 =============
 email : x...@gmail.com
 firstname : xyz

 email : a...@gmail.com
 firstname : abc


 here i want only one result(2nd result) that is where both the

field is satisfied.
how to achieve that?

 note that user can input in email partial values as " gmail.com

http://gmail.com ", thats ahy i am using wildcard there.

 Thanks in advanced.

 Mohsin



 --



> > > 
--
David Pilato
http://www.scrutmydocs.org/ <http://www.scrutmydocs.org/>
http://dev.david.pilato.fr/ <http://dev.david.pilato.fr/>
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

Thanks a Ton !
it is working fine as u said.
i may be using other way around.

now problem is firstname/email may be blank !
so wen it comes blank(either of them) no results are populated.
i tried with should it is giving result(when one field is blank) but wen we
search with firstname and email it has multiple record rather than one
single record.

shall i use other stuffs like filters and all that to achieve this !

Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 16:23:14 UTC, David Pilato wrote:

FYI, I created a full test case here:
GitHub - elasticsearchfr/elasticsearch-java-tests: Elasticsearch Java Tests

HTH
David.

Le 27 novembre 2012 à 16:49, David Pilato <da...@pilato.fr <javascript:>>
a écrit :

Have a look here: Test case for must clause · GitHub

It works fine for me.

David.

Le 27 novembre 2012 à 16:24, mohsin husen <smh...@gmail.com <javascript:>>
a écrit :

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

a...@gmail.com <javascript:>
x...@gmail.com <javascript:>

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email",
""+criteria.getEmail()+""))
.should(termQuery("firstName", criteria.getFirstName()));

Result

email : a...@gmail.com <javascript:> , Firstname : abc
email : x...@gmail.com <javascript:> , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as
abc so it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning
any hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:

Not sure to fully understand but did you try with must clauses instead
of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen < smh...@gmail.com> a écrit :

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with * gmail.com and have firstname
as "abc"

email : " gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : x...@gmail.com
firstname : xyz

email : a...@gmail.com
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as " gmail.com", thats
ahy i am using wildcard there.

Thanks in advanced.

Mohsin

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

it is working fine now.
my silly mistake.
really appreciated your help David !
thanks a ton !
ES looks quite interesting and innovative solution to search.
Cheers !

On Tuesday, 27 November 2012 16:31:04 UTC, mohsin husen wrote:

Thanks a Ton !
it is working fine as u said.
i may be using other way around.

now problem is firstname/email may be blank !
so wen it comes blank(either of them) no results are populated.
i tried with should it is giving result(when one field is blank) but wen
we search with firstname and email it has multiple record rather than one
single record.

shall i use other stuffs like filters and all that to achieve this !

Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 16:23:14 UTC, David Pilato wrote:

FYI, I created a full test case here:
GitHub - elasticsearchfr/elasticsearch-java-tests: Elasticsearch Java Tests

HTH
David.

Le 27 novembre 2012 à 16:49, David Pilato da...@pilato.fr a écrit :

Have a look here: Test case for must clause · GitHub

It works fine for me.

David.

Le 27 novembre 2012 à 16:24, mohsin husen smh...@gmail.com a écrit :

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

a...@gmail.com
x...@gmail.com

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email",
""+criteria.getEmail()+""))
.should(termQuery("firstName",
criteria.getFirstName()));

Result

email : a...@gmail.com , Firstname : abc
email : x...@gmail.com , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as
abc so it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning
any hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:

Not sure to fully understand but did you try with must clauses instead
of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen < smh...@gmail.com> a écrit :

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with * gmail.com and have
firstname as "abc"

email : " gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : x...@gmail.com
firstname : xyz

email : a...@gmail.com
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as " gmail.com", thats
ahy i am using wildcard there.

Thanks in advanced.

Mohsin

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

it still displays the multiple record with should.
:frowning:

On Tuesday, 27 November 2012 16:31:04 UTC, mohsin husen wrote:

Thanks a Ton !
it is working fine as u said.
i may be using other way around.

now problem is firstname/email may be blank !
so wen it comes blank(either of them) no results are populated.
i tried with should it is giving result(when one field is blank) but wen
we search with firstname and email it has multiple record rather than one
single record.

shall i use other stuffs like filters and all that to achieve this !

Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 16:23:14 UTC, David Pilato wrote:

FYI, I created a full test case here:
GitHub - elasticsearchfr/elasticsearch-java-tests: Elasticsearch Java Tests

HTH
David.

Le 27 novembre 2012 à 16:49, David Pilato da...@pilato.fr a écrit :

Have a look here: Test case for must clause · GitHub

It works fine for me.

David.

Le 27 novembre 2012 à 16:24, mohsin husen smh...@gmail.com a écrit :

Thanks David for reply :slight_smile:

Let me repeat my use case.

====================================================
Case 1 : (which is working as expected)

email : gmail.com

query

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))

result : (it gives all emails where we have gmail.com)

a...@gmail.com
x...@gmail.com

================================================
Case 2 : (now here i have problem ! )

email : gmail.com
firstName : abc

Query:

boolQuery()
.should(wildcardQuery("email",
""+criteria.getEmail()+""))
.should(termQuery("firstName",
criteria.getFirstName()));

Result

email : a...@gmail.com , Firstname : abc
email : x...@gmail.com , Firstname : xyz

problem : i am searching a user who has email of gmail.com and name as
abc so it should return only one result rather than two results.

David, I also tried must after your suggestion but it is not returning
any hit.

Please advice,
Thanks in advanced
Mohsin H

On Tuesday, 27 November 2012 15:02:41 UTC, David Pilato wrote:

Not sure to fully understand but did you try with must clauses instead
of should?

David.

Le 27 novembre 2012 à 15:54, mohsin husen < smh...@gmail.com> a écrit :

I am searching using the JAVA API as follows :

Test case 1 : (it should return user with * gmail.com and have
firstname as "abc"

email : " gmail.com"
firstname : "abc"

boolQuery().should(wildcardQuery("email", ""+criteria.getEmail()+""))
.should(wildcardQuery("firstname",
""+criteria.getFirstName()+""));

result :

email : x...@gmail.com
firstname : xyz

email : a...@gmail.com
firstname : abc

here i want only one result(2nd result) that is where both the field is
satisfied.
how to achieve that?

note that user can input in email partial values as " gmail.com", thats
ahy i am using wildcard there.

Thanks in advanced.

Mohsin

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--

--
David Pilato
http://www.scrutmydocs.org/
http://dev.david.pilato.fr/
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

--