Prefix question

Hi,

I have a question about the use of the prefix filter. Suppose I have
two records with a field "phrase" which have the values "apple banana"
and "banana cherry" and lets assume I want to make a prefix-search for
"b" on phrase (autocompletion). What do I have to do, to only get the
record "banana cherry" but not the record "apple banana"?

Right now I use the following filter-query:

{
"filter": {
"bool": {
"must": [
{
"prefix": {
"phrase": "z"
}
}
]
}
}
}

Hi Valentin,

You need to make sure your fields are not broken into tokens on space,
but just "left edge n-gramed".

Otis

Sematext is hiring Elasticsearch / Solr developers --

On Jan 17, 11:13 am, Valentin plet...@gmail.com wrote:

Hi,

I have a question about the use of the prefix filter. Suppose I have
two records with a field "phrase" which have the values "apple banana"
and "banana cherry" and lets assume I want to make a prefix-search for
"b" on phrase (autocompletion). What do I have to do, to only get the
record "banana cherry" but not the record "apple banana"?

Right now I use the following filter-query:

{
"filter": {
"bool": {
"must": [
{
"prefix": {
"phrase": "z"
}
}
]
}
}

}

Another option is to use text query with the phrase prefix option:
Elasticsearch Platform — Find real-time answers at scale | Elastic.

On Wed, Jan 18, 2012 at 7:38 AM, Otis Gospodnetic <
otis.gospodnetic@gmail.com> wrote:

Hi Valentin,

You need to make sure your fields are not broken into tokens on space,
but just "left edge n-gramed".

Otis

Sematext is hiring Elasticsearch / Solr developers --
Jobs - Sematext

On Jan 17, 11:13 am, Valentin plet...@gmail.com wrote:

Hi,

I have a question about the use of the prefix filter. Suppose I have
two records with a field "phrase" which have the values "apple banana"
and "banana cherry" and lets assume I want to make a prefix-search for
"b" on phrase (autocompletion). What do I have to do, to only get the
record "banana cherry" but not the record "apple banana"?

Right now I use the following filter-query:

{
"filter": {
"bool": {
"must": [
{
"prefix": {
"phrase": "z"
}
}
]
}
}

}