Re: Type Ahead feature for contact list

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

--

Itamar Syn-Hershko
http://code972.com | @synhershko https://twitter.com/synhershko
Freelance Developer & Consultant
Author of RavenDB in Action http://manning.com/synhershko/

On Tue, Jun 17, 2014 at 8:03 PM, Omi umang.in60@gmail.com wrote:

Hello All

I am quite new for elasticsearch and reading elasticsearch related
documents from few days. I am creating a contact list search for my
application, where contacts are stored in <lastname (nickname),
firstname> format.

I am facing a problem while searching the name using java client.

for example few contacts in my application are:

Smith (Mik), Mike
Smith, John
Gomes, Madona
Fernandis, Madona
Trav (Mik), John

Now, when I search the name with java client api, the search term split in
tokens and return wrong results:

Case 1:
QueryBuilder qb = QueryBuilders.queryString("John Gomes*");
Expected Result: 0
Actual Result: "Smith, John", "Gomes, Madona" and "Trav (Mik), John"

Case 2:
QueryBuilder qb = QueryBuilders.queryString("Smi* John");
Expected Result: "Smith, John"
Actual Result: "Smith, John" , "Smith (Mik), Mike" and "Trav (Mik), John"

Case 3:
QueryBuilder qb = QueryBuilders.queryString("Gomes Madona");
Expected Result: "Gomes, Madona"
Actual Result: "Gomes, Madona" and "Fernandis, Madona"

This is heppening because search term split into two tokens and it's
searching in result for 2 separate words.

I tried with "not_analyzed" in mapping for name field but it restricted me
to search case sensitive and in record stored order only, but as per my
usecase user can search with any order in name. In case of two or more
words query I need to display exact results and in case of one word query I
have to display results containing search term.

Please suggest how to get expected results. What config changes I need to
do to get correct results.

Thanks in advance.

Regards,
Omi

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/421b5e94-199a-4d4d-8b58-5ae650f53cb4%40googlegroups.com
https://groups.google.com/d/msgid/elasticsearch/421b5e94-199a-4d4d-8b58-5ae650f53cb4%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAHTr4ZsGmOiToMW9qDb6q8SmomoB63R%3DUGzDW9Z%3D2iVz1vhimA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Thanks for the help.

but in this case I have to write all possible combinations in suggest field, alsocould you please suggest how to write following query in java

curl -X POST localhost:9200/hotels/_suggest -d '
{
"hotels" : {
"text" : "m",
"completion" : {
"field" : "name_suggest"
}
}
}'

Wouldn't make sense to store the three elements in separated fields?

On Jun 17, 2014, at 1:03 PM, Omi umang.in60@gmail.com wrote:

Hello All

I am quite new for elasticsearch and reading elasticsearch related documents from few days. I am creating a contact list search for my application, where contacts are stored in <lastname (nickname), firstname> format.

I am facing a problem while searching the name using java client.

for example few contacts in my application are:

Smith (Mik), Mike
Smith, John
Gomes, Madona
Fernandis, Madona
Trav (Mik), John

Now, when I search the name with java client api, the search term split in tokens and return wrong results:

Case 1:
QueryBuilder qb = QueryBuilders.queryString("John Gomes*");
Expected Result: 0
Actual Result: "Smith, John", "Gomes, Madona" and "Trav (Mik), John"

Case 2:
QueryBuilder qb = QueryBuilders.queryString("Smi* John");
Expected Result: "Smith, John"
Actual Result: "Smith, John" , "Smith (Mik), Mike" and "Trav (Mik), John"

Case 3:
QueryBuilder qb = QueryBuilders.queryString("Gomes Madona");
Expected Result: "Gomes, Madona"
Actual Result: "Gomes, Madona" and "Fernandis, Madona"

This is heppening because search term split into two tokens and it's searching in result for 2 separate words.

I tried with "not_analyzed" in mapping for name field but it restricted me to search case sensitive and in record stored order only, but as per my usecase user can search with any order in name. In case of two or more words query I need to display exact results and in case of one word query I have to display results containing search term.

Please suggest how to get expected results. What config changes I need to do to get correct results.

Thanks in advance.

Regards,
Omi

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/421b5e94-199a-4d4d-8b58-5ae650f53cb4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

VII Escuela Internacional de Verano en la UCI del 30 de junio al 11 de julio de 2014. Ver www.uci.cu

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/364CE144-02C0-46B2-AA73-217420566179%40uci.cu.
For more options, visit https://groups.google.com/d/optout.