Prefix query search words rather than sentence

Hi All,

I m trying to build a query to search all documents starts with single
alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole
sentence.

Anyway that i could search the document that only have single occurence of
'A' in the 1st letter ?

Thanks,.

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

It's because you are using default analyzer which break phrases into words then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole sentence.

Anyway that i could search the document that only have single occurence of 'A' in the 1st letter ?

Thanks,.

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

How do i change the mapping ? and do i need to delete and reindex ? because
i have millions of records there ?

On Fri, Sep 13, 2013 at 2:56 PM, David Pilato david@pilato.fr wrote:

It's because you are using default analyzer which break phrases into words
then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single
alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole
sentence.

Anyway that i could search the document that only have single occurence of
'A' in the 1st letter ?

Thanks,.

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 change the mapping using PUT Mapping API: Elasticsearch Platform — Find real-time answers at scale | Elastic
See also: Elasticsearch Platform — Find real-time answers at scale | Elastic and Elasticsearch Platform — Find real-time answers at scale | Elastic

My bet here (I don't have much info about your use case) is that you somehow need a Simple Analyzer Elasticsearch Platform — Find real-time answers at scale | Elastic

You can use multifield as well to keep your current mapping as is and add another one: Elasticsearch Platform — Find real-time answers at scale | Elastic

3 choices from there:
Delete your index, Reindex: you will have a fresh clean new index (you don't need multi field)
Update the mapping, Reindex (aka Update each document): each document will have a new version
Update the mapping: only new indexed documents will benefit from this new analyzer

Does it help?

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

Le 13 sept. 2013 à 09:15, chee hoo lum cheehoo84@gmail.com a écrit :

How do i change the mapping ? and do i need to delete and reindex ? because i have millions of records there ?

On Fri, Sep 13, 2013 at 2:56 PM, David Pilato david@pilato.fr wrote:
It's because you are using default analyzer which break phrases into words then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole sentence.

Anyway that i could search the document that only have single occurence of 'A' in the 1st letter ?

Thanks,.

--
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 a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

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

Hi David,

First of all thanks.
Basically what i wanted is only search a particular field that have a
prefix of eg : 'A' in 1st letter.

More example :

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

Result expected to return is :

  1. "DISPLAY_NAME": "Adele Sings", //YES

2)"DISPLAY_NAME": "Alex Dance", // YES

3)"DISPLAY_NAME": "Ndek Te Angenan (Lombok)", //NO

4)"DISPLAY_NAME": "Ndek Ae Tngenan (Lombok)", //NO

5)"DISPLAY_NAME": "NAek ee Tngenan (Lombok)", //NO

More comment inlined in red in your previous replies.

Thanks.

On Fri, Sep 13, 2013 at 3:23 PM, David Pilato david@pilato.fr wrote:

You change the mapping using PUT Mapping API:
Elasticsearch Platform — Find real-time answers at scale | Elastic
See also: Elasticsearch Platform — Find real-time answers at scale | Elastic and
Elasticsearch Platform — Find real-time answers at scale | Elastic

My bet here (I don't have much info about your use case) is that you
somehow need a Simple Analyzer
Elasticsearch Platform — Find real-time answers at scale | Elastic

This doesn't explain how i gonna apply the analzyer to the field nor how
to create an analyzer.

You can use multifield as well to keep your current mapping as is and add
another one:
Elasticsearch Platform — Find real-time answers at scale | Elastic

3 choices from there:

  • Delete your index, Reindex: you will have a fresh clean new index
    (you don't need multi field)

        This might not be my best choice due to developers need the
    

data.

  • Update the mapping, Reindex (aka Update each document): each
    document will have a new version

        Doing this will not delete all the current documents and it
    

will replace each at a time ?

  • Update the mapping: only new indexed documents will benefit from
    this new analyzer

    Not smtg i wanted to :)
    

Does it help?

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 13 sept. 2013 à 09:15, chee hoo lum cheehoo84@gmail.com a écrit :

How do i change the mapping ? and do i need to delete and reindex ?
because i have millions of records there ?

On Fri, Sep 13, 2013 at 2:56 PM, David Pilato david@pilato.fr wrote:

It's because you are using default analyzer which break phrases into
words then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single
alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole
sentence.

Anyway that i could search the document that only have single occurence
of 'A' in the 1st letter ?

Thanks,.

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

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

Something like:

curl -XPOST "http://localhost:9200/yourindex/yourtype/_mapping" -d '
{
"yourtype":{
"properties":{
"yourfield":{
"type":"multi_field",
"fields":{
"yourfield":{"type":"string"},
"simple":{"type":"string","analyzer":"simple"}
}
}
}
}
}
'

Doing this will not delete all the current documents and it will replace each at a time ?
Behind the scene, yes. It will create a new version of your doc.

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

Le 13 sept. 2013 à 10:07, chee hoo lum cheehoo84@gmail.com a écrit :

Hi David,

First of all thanks.
Basically what i wanted is only search a particular field that have a prefix of eg : 'A' in 1st letter.

More example :

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

Result expected to return is :

  1. "DISPLAY_NAME": "Adele Sings", //YES

2)"DISPLAY_NAME": "Alex Dance", // YES

3)"DISPLAY_NAME": "Ndek Te Angenan (Lombok)", //NO

4)"DISPLAY_NAME": "Ndek Ae Tngenan (Lombok)", //NO

5)"DISPLAY_NAME": "NAek ee Tngenan (Lombok)", //NO

More comment inlined in red in your previous replies.

Thanks.

On Fri, Sep 13, 2013 at 3:23 PM, David Pilato david@pilato.fr wrote:
You change the mapping using PUT Mapping API: Elasticsearch Platform — Find real-time answers at scale | Elastic
See also: Elasticsearch Platform — Find real-time answers at scale | Elastic and Elasticsearch Platform — Find real-time answers at scale | Elastic

My bet here (I don't have much info about your use case) is that you somehow need a Simple Analyzer Elasticsearch Platform — Find real-time answers at scale | Elastic

This doesn't explain how i gonna apply the analzyer to the field nor how to create an analyzer.

You can use multifield as well to keep your current mapping as is and add another one: Elasticsearch Platform — Find real-time answers at scale | Elastic

3 choices from there:
Delete your index, Reindex: you will have a fresh clean new index (you don't need multi field)
This might not be my best choice due to developers need the data.
Update the mapping, Reindex (aka Update each document): each document will have a new version
Doing this will not delete all the current documents and it will replace each at a time ?

Update the mapping: only new indexed documents will benefit from this new analyzer
Not smtg i wanted to :slight_smile:

Does it help?

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

Le 13 sept. 2013 à 09:15, chee hoo lum cheehoo84@gmail.com a écrit :

How do i change the mapping ? and do i need to delete and reindex ? because i have millions of records there ?

On Fri, Sep 13, 2013 at 2:56 PM, David Pilato david@pilato.fr wrote:
It's because you are using default analyzer which break phrases into words then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole sentence.

Anyway that i could search the document that only have single occurence of 'A' in the 1st letter ?

Thanks,.

--
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 a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 a topic in the Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

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

Hi David,

Thanks alot. I will tried it. Sorry for asking such detail due to the
urgency and too many tasks on my hand. :slight_smile:
Appreciate your help.

Cyril

On Fri, Sep 13, 2013 at 4:29 PM, David Pilato david@pilato.fr wrote:

Something like:

curl -XPOST "http://localhost:9200/yourindex/yourtype/_mapping" -d '
{
"yourtype":{
"properties":{
"yourfield":{
"type":"multi_field",
"fields":{
"yourfield":{"type":"string"},
"simple":{"type":"string","analyzer":"simple"}
}
}
}
}
}
'

Doing this will not delete all the current documents and it will
replace each at a time ?
Behind the scene, yes. It will create a new version of your doc.

--
David Pilato | Technical Advocate | Elasticsearch.com
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 13 sept. 2013 à 10:07, chee hoo lum cheehoo84@gmail.com a écrit :

Hi David,

First of all thanks.
Basically what i wanted is only search a particular field that have a
prefix of eg : 'A' in 1st letter.

More example :

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

Result expected to return is :

  1. "DISPLAY_NAME": "Adele Sings", //YES

2)"DISPLAY_NAME": "Alex Dance", // YES

3)"DISPLAY_NAME": "Ndek Te Angenan (Lombok)", //NO

4)"DISPLAY_NAME": "Ndek Ae Tngenan (Lombok)", //NO

5)"DISPLAY_NAME": "NAek ee Tngenan (Lombok)", //NO

More comment inlined in red in your previous replies.

Thanks.

On Fri, Sep 13, 2013 at 3:23 PM, David Pilato david@pilato.fr wrote:

You change the mapping using PUT Mapping API:
Elasticsearch Platform — Find real-time answers at scale | Elastic
See also: Elasticsearch Platform — Find real-time answers at scale | Elastic and
Elasticsearch Platform — Find real-time answers at scale | Elastic

My bet here (I don't have much info about your use case) is that you
somehow need a Simple Analyzer
Elasticsearch Platform — Find real-time answers at scale | Elastic

This doesn't explain how i gonna apply the analzyer to the field nor
how to create an analyzer.

You can use multifield as well to keep your current mapping as is and add
another one:
Elasticsearch Platform — Find real-time answers at scale | Elastic

3 choices from there:

  • Delete your index, Reindex: you will have a fresh clean new index
    (you don't need multi field)

        This might not be my best choice due to developers need the
    

data.

  • Update the mapping, Reindex (aka Update each document): each
    document will have a new version

        Doing this will not delete all the current documents and it
    

will replace each at a time ?

  • Update the mapping: only new indexed documents will benefit from
    this new analyzer

    Not smtg i wanted to :)
    

Does it help?

--
David Pilato | Technical Advocate | *Elasticsearch.comhttp://elasticsearch.com/
*
@dadoonet https://twitter.com/dadoonet | @elasticsearchfrhttps://twitter.com/elasticsearchfr
| @scrutmydocs https://twitter.com/scrutmydocs

Le 13 sept. 2013 à 09:15, chee hoo lum cheehoo84@gmail.com a écrit :

How do i change the mapping ? and do i need to delete and reindex ?
because i have millions of records there ?

On Fri, Sep 13, 2013 at 2:56 PM, David Pilato david@pilato.fr wrote:

It's because you are using default analyzer which break phrases into
words then index them.
You need to change your mapping here.

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

Le 13 sept. 2013 à 08:48, cyrilforce cheehoo84@gmail.com a écrit :

Hi All,

I m trying to build a query to search all documents starts with single
alphabets eg : A

{
"query" : {
"prefix" : {
"DISPLAY_NAME" : "a"

  }}

}

However the result returned is

"DISPLAY_NAME": "Ndek Te Angenan (Lombok)",

It seems like it is search every single words rather than the whole
sentence.

Anyway that i could search the document that only have single occurence
of 'A' in the 1st letter ?

Thanks,.

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

--
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 a topic in the
Google Groups "elasticsearch" group.
To unsubscribe from this topic, visit
https://groups.google.com/d/topic/elasticsearch/xOmcYMr8j_k/unsubscribe.
To unsubscribe from this group and all its topics, send an email to
elasticsearch+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

--
Regards,

Chee Hoo

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