Get matching term

Hi!

I have a document that have some tags for instance.

{name: 'foo', tags: ['black', 'green', 'yellow', 'saturday night
fever']}

The tags are not known, a user can insert anything.

I want to provide autocompletion so users can reuse tags already used
by others. To do so I do a prefix query.

I would love if the query could also return the original term that
matched the query. In the example above, if I search for 'satur' I
would like to get 'saturday night fever' tag instead of the whole
document.

Is there any way to achieve that?

Thank's in advance!

There isn't a way to do it, unless you create an autocomplete index with
tags as documents, or maybe do the matching yourself on the client side (if
its a prefix based one, its simple).

On Tue, Jul 19, 2011 at 11:03 AM, Pau masylum@gmail.com wrote:

Hi!

I have a document that have some tags for instance.

{name: 'foo', tags: ['black', 'green', 'yellow', 'saturday night
fever']}

The tags are not known, a user can insert anything.

I want to provide autocompletion so users can reuse tags already used
by others. To do so I do a prefix query.

I would love if the query could also return the original term that
matched the query. In the example above, if I search for 'satur' I
would like to get 'saturday night fever' tag instead of the whole
document.

Is there any way to achieve that?

Thank's in advance!

I´m currently doing it client side but it feels kind of "hackish". I
would probably store the tags in a different index as you said. :slight_smile:

On Jul 19, 11:41 pm, Shay Banon shay.ba...@elasticsearch.com wrote:

There isn't a way to do it, unless you create an autocomplete index with
tags as documents, or maybe do the matching yourself on the client side (if
its a prefix based one, its simple).

On Tue, Jul 19, 2011 at 11:03 AM, Pau masy...@gmail.com wrote:

Hi!

I have a document that have some tags for instance.

{name: 'foo', tags: ['black', 'green', 'yellow', 'saturday night
fever']}

The tags are not known, a user can insert anything.

I want to provide autocompletion so users can reuse tags already used
by others. To do so I do a prefix query.

I would love if the query could also return the original term that
matched the query. In the example above, if I search for 'satur' I
would like to get 'saturday night fever' tag instead of the whole
document.

Is there any way to achieve that?

Thank's in advance!