Text Phrase Query

Hello

We want to get the functionality of text_phrase_prefix but with
highlights. To search exact matching of phrase without ending last
word.

Suppose we have indexed following text:
Elasticsearch works perfectly for us.

Scenario 1:
Search String: ElasticSearch works
Result: Entry was found

Scenario 2:
Search String: ElasticSearch perfectly
Result: No entry was found

Scenario 3:
Search String: ElasticSearch wor
Result: Entry was found

Scenario 4:
Search String: ElasticS
Result: Entry was found

Scenario 5:
Search String: ElasticS wor
Result: No entry was found

Any suggestions implementing this?
Thanks in advnace

On Mon, 2011-10-10 at 07:16 -0700, Alexander Nemsadze wrote:

Hello

We want to get the functionality of text_phrase_prefix but with
highlights. To search exact matching of phrase without ending last
word.

Any suggestions implementing this?

A simple regex on the the highlighted phrase would work, eg, in Perl
(assuming your highlighting uses tags):

s{([^<\s]+)}{\1}g

clint

Hello, thanks for your response, but in fact we are trying to pass the
query string to Elasticsearch, not processing local strings.
Elastic search makes highlight for you adding start and end tags to
it.

On Oct 10, 6:25 pm, Clinton Gormley cl...@traveljury.com wrote:

On Mon, 2011-10-10 at 07:16 -0700, Alexander Nemsadze wrote:

Hello

We want to get the functionality of text_phrase_prefix but with
highlights. To search exact matching of phrase without ending last
word.
Any suggestions implementing this?

A simple regex on the the highlighted phrase would work, eg, in Perl
(assuming your highlighting uses tags):

s{([^<\s]+)}{\1}g

clint

We want to get exact functionality of text_phrase query, except it
must be allowed not finishing last word.

On Mon, 2011-10-10 at 07:35 -0700, Alexander Nemsadze wrote:

Hello, thanks for your response, but in fact we are trying to pass the
query string to Elasticsearch, not processing local strings.
Elastic search makes highlight for you adding start and end tags to
it.

Hi Alexander

My regex was for post-processing results from elasticsearch to achieve
what you want, ie instead of a search for "lang" returning

"a language in common use"

my regex would convert that to

"a language in common use"

which is what you want

clint

Thanks for that solution, but my problem is that I have no "a
language in common use" highlighted text returned from
elasticsearch, as text_phrase does not search anything when entering
part of the word.

text_phrase_prefix works perfectly for me, except highlight, no
highlight is returned when I enter one word and half part of the
second word, for example - Steve Jo - will return entry, but no
highlight part exists in response JSON. If I enter - Ste - everything
is OK.

On Oct 10, 7:20 pm, Clinton Gormley cl...@traveljury.com wrote:

On Mon, 2011-10-10 at 07:35 -0700, Alexander Nemsadze wrote:

Hello, thanks for your response, but in fact we are trying to pass the
query string to Elasticsearch, not processing local strings.
Elastic search makes highlight for you adding start and end tags to
it.

Hi Alexander

My regex was for post-processing results from elasticsearch to achieve
what you want, ie instead of a search for "lang" returning

"a language in common use"

my regex would convert that to

"a language in common use"

which is what you want

clint

text_phrase_prefix works perfectly for me, except highlight, no
highlight is returned when I enter one word and half part of the
second word, for example - Steve Jo - will return entry, but no
highlight part exists in response JSON. If I enter - Ste - everything
is OK.

Ah right - apologies. I missed the fact that highlighting doesn't work
at all with text_phrase_prefix.

I don't know why this is the case. I suggest opening an issue

clint

To explain in one more way, we want to get result elasticsearch to
search for us exactly as database LIKE 'something mor%' query does and
with highlights

On Oct 10, 8:02 pm, Clinton Gormley cl...@traveljury.com wrote:

text_phrase_prefix works perfectly for me, except highlight, no
highlight is returned when I enter one word and half part of the
second word, for example - Steve Jo - will return entry, but no
highlight part exists in response JSON. If I enter - Ste - everything
is OK.

Ah right - apologies. I missed the fact that highlighting doesn't work
at all with text_phrase_prefix.

I don't know why this is the case. I suggest opening an issue

clint

Can you have term vectors stored for the field you highlight on, and see if
it helps? You will need to reindex the data. Storing term vectors will cause
a different highlighting implementation to be used (see here:
Elasticsearch Platform — Find real-time answers at scale | Elastic.

On Tue, Oct 11, 2011 at 8:13 AM, Alexander Nemsadze <
alexander.nemsadze@azry.com> wrote:

To explain in one more way, we want to get result elasticsearch to
search for us exactly as database LIKE 'something mor%' query does and
with highlights

On Oct 10, 8:02 pm, Clinton Gormley cl...@traveljury.com wrote:

text_phrase_prefix works perfectly for me, except highlight, no
highlight is returned when I enter one word and half part of the
second word, for example - Steve Jo - will return entry, but no
highlight part exists in response JSON. If I enter - Ste - everything
is OK.

Ah right - apologies. I missed the fact that highlighting doesn't work
at all with text_phrase_prefix.

I don't know why this is the case. I suggest opening an issue

clint