Searching terms

Hi,

I have a following question. Is it possible for Elasticsearch to index text
fields to allow searching complex terms like 'how are you'? I would like to
find documents with fields containing exact term 'how are you', not only
words 'how', 'are' and 'you'. How should I index such fields to allow
searching like this, and how should I build such a request?

Thanks for help.

Best regards.
Marcin.

You can define a keyword mapping. ES won't touch what you index.
Or you can define to use a AND operator instead of OR (default) in your
query
Or you can use lucene syntax to query on +how +are +you

I think that there are many other ways to do it...

HTH
David.

Le 22 mars 2012 à 14:41, Marcin Dojwa m.dojwa@livechatinc.com a écrit :

I have a following question. Is it possible for Elasticsearch to index text
fields to allow searching complex terms like 'how are you'? I would like to
find documents with fields containing exact term 'how are you', not only
words 'how', 'are' and 'you'. How should I index such fields to allow
searching like this, and how should I build such a request?

Thanks for help.

Best regards.
Marcin.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

Hi thanks, but I think you misunderstood me. As I understand your examples
will find all the documents with fields containing all of the given words
'how', 'are' and 'you', so the matching fields would be:

  1. How are you today?
  2. How something you anything are something else.
  3. ...

right ?

But I want to find the fields that contains exactly 'how are you' so the
matching 1 from above would be the only correct match.

Best regards.

2012/3/22 david@pilato.fr david@pilato.fr

**

You can define a keyword mapping. ES won't touch what you index.

Or you can define to use a AND operator instead of OR (default) in your
query

Or you can use lucene syntax to query on +how +are +you

I think that there are many other ways to do it...

HTH

David.

Le 22 mars 2012 à 14:41, Marcin Dojwa m.dojwa@livechatinc.com a écrit :

Hi,

I have a following question. Is it possible for Elasticsearch to index
text fields to allow searching complex terms like 'how are you'? I would
like to find documents with fields containing exact term 'how are you', not
only words 'how', 'are' and 'you'. How should I index such fields to allow
searching like this, and how should I build such a request?

Thanks for help.

Best regards.
Marcin.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

So you want ES to index field without tokenizing its content.
A keyword analyzer will do it. By default, ES use the standard analyzer.

That's the first proposal I wrote.

You have to define it at index time. If ES has already tokenized the field, you won't be able to search exact sentence.

Does it answer to your needs ?

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 22 mars 2012 à 15:26, Marcin Dojwa m.dojwa@livechatinc.com a écrit :

Hi thanks, but I think you misunderstood me. As I understand your examples will find all the documents with fields containing all of the given words 'how', 'are' and 'you', so the matching fields would be:

  1. How are you today?
  2. How something you anything are something else.
  3. ...

right ?

But I want to find the fields that contains exactly 'how are you' so the matching 1 from above would be the only correct match.

Best regards.

2012/3/22 david@pilato.fr david@pilato.fr
You can define a keyword mapping. ES won't touch what you index.
Or you can define to use a AND operator instead of OR (default) in your query
Or you can use lucene syntax to query on +how +are +you

I think that there are many other ways to do it...

HTH
David.

Le 22 mars 2012 à 14:41, Marcin Dojwa m.dojwa@livechatinc.com a écrit :

Hi,

I have a following question. Is it possible for Elasticsearch to index text fields to allow searching complex terms like 'how are you'? I would like to find documents with fields containing exact term 'how are you', not only words 'how', 'are' and 'you'. How should I index such fields to allow searching like this, and how should I build such a request?

Thanks for help.

Best regards.
Marcin.

--
David Pilato
http://dev.david.pilato.fr/
Twitter : @dadoonet

On Thu, 2012-03-22 at 15:36 +0100, David Pilato wrote:

So you want ES to index field without tokenizing its content.
A keyword analyzer will do it. By default, ES use the standard
analyzer.

That's the first proposal I wrote.

You have to define it at index time. If ES has already tokenized the
field, you won't be able to search exact sentence.

I think he is asking about a phrase search, in which case the
'text_phrase' query or a query_string query would work

clint

Does it answer to your needs ?

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 22 mars 2012 Ã 15:26, Marcin Dojwa m.dojwa@livechatinc.com a
écrit :

Hi thanks, but I think you misunderstood me. As I understand your
examples will find all the documents with fields containing all of
the given words 'how', 'are' and 'you', so the matching fields would
be:

  1. How are you today?
  2. How something you anything are something else.
  3. ...

right ?

But I want to find the fields that contains exactly 'how are you' so
the matching 1 from above would be the only correct match.

Best regards.

2012/3/22 david@pilato.fr david@pilato.fr
You can define a keyword mapping. ES won't touch what you
index.

    Or you can define to use a AND operator instead of OR
    (default) in your query 
    
    Or you can use lucene syntax to query on +how +are +you 
    
    
    I think that there are many other ways to do it... 
    
    
    HTH 
    
    David. 
    
    
    
    Le 22 mars 2012 Ã  14:41, Marcin Dojwa
    <m.dojwa@livechatinc.com> a écrit : 
    
            Hi, 
             
            I have a following question. Is it possible for
            Elasticsearch to index text fields to allow
            searching complex terms like 'how are you'? I would
            like to find documents with fields containing exact
            term 'how are you', not only words 'how', 'are' and
            'you'. How should I index such fields to allow
            searching like this, and how should I build such a
            request?
             
            Thanks for help.
             
            Best regards.
            Marcin.
    
      
    
    -- 
    David Pilato 
    http://dev.david.pilato.fr/ 
    Twitter : @dadoonet 

Yes, I meant the phrase search :slight_smile: Thank you all for help, that's great that
it is possible :slight_smile: I will check this as soon as possible.

Best regards.

W dniu czwartek, 22 marca 2012 użytkownik Clinton Gormley <
clint@traveljury.com> napisał:

On Thu, 2012-03-22 at 15:36 +0100, David Pilato wrote:

So you want ES to index field without tokenizing its content.
A keyword analyzer will do it. By default, ES use the standard
analyzer.

That's the first proposal I wrote.

You have to define it at index time. If ES has already tokenized the
field, you won't be able to search exact sentence.

I think he is asking about a phrase search, in which case the
'text_phrase' query or a query_string query would work

clint

Does it answer to your needs ?

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 22 mars 2012 à 15:26, Marcin Dojwa m.dojwa@livechatinc.com a
écrit :

Hi thanks, but I think you misunderstood me. As I understand your
examples will find all the documents with fields containing all of
the given words 'how', 'are' and 'you', so the matching fields would
be:

  1. How are you today?
  2. How something you anything are something else.
  3. ...

right ?

But I want to find the fields that contains exactly 'how are you' so
the matching 1 from above would be the only correct match.

Best regards.

2012/3/22 david@pilato.fr david@pilato.fr
You can define a keyword mapping. ES won't touch what you
index.

    Or you can define to use a AND operator instead of OR
    (default) in your query

    Or you can use lucene syntax to query on +how +are +you


    I think that there are many other ways to do it...


    HTH

    David.



    Le 22 mars 2012 à 14:41, Marcin Dojwa
    <m.dojwa@livechatinc.com> a écrit :

            Hi,

            I have a following question. Is it possible for
            Elasticsearch to index text fields to allow
            searching complex terms like 'how are you'? I would
            like to find documents with fields containing exact
            term 'how are you', not only words 'how', 'are' and
            'you'. How should I index such fields to allow
            searching like this, and how should I build such a
            request?

            Thanks for help.

            Best regards.
            Marcin.



    --
    David Pilato
    http://dev.david.pilato.fr/
    Twitter : @dadoonet

I think he is asking about a phrase search, in which case the
'text_phrase' query or a query_string query would work

Thanks Clint.

I was not aware of it.

David.

'text_phrase' works perfect, thank you very much.

Best regards.
Marcin.

2012/3/22 david@pilato.fr david@pilato.fr

**

I think he is asking about a phrase search, in which case the

'text_phrase' query or a query_string query would work

Thanks Clint.

I was not aware of it.

David.