Specify metadata per word/term in a string


(Neeraj Makam) #1

Hi

Given a text,say "hello elastic search world",
is there a way i can associate a field or some metadata per word in the
text on which i can later query?
for eg: give code number to each word, and should be able to search like
text = "hello" AND code = "25"
i.e return all "hello" words which have 25 in their code metadata.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/f5f40059-e9e7-4a05-93f8-aacdff26abb0%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(vineeth mohan-2) #2

Hello Neeraj ,

First of all you cant return a "hello" from Elasticsearch.
Elasticsearch works on feed level basis.
Which means if you want to search hello , you will get the feed with the
text "hello elasticsearch search world" but not just hello.

Only way I can think of create a different document for each word. So a
document would look like -

{
"word" : "hello",
"code" : 25
}

here , you can get it worked.

If you want to retrieve the text also , give it as follows -

{
"text" : "hello from Elasticsearch" ,
"words" : [
{ "word" : "hello" , "count" : 25 } ,
{ "word" : "from" , "count" : 22}
]
}

WHERE words field is nested type.

Thanks
Vineeth

On Wed, Apr 30, 2014 at 4:36 PM, Neeraj Makam neeraj23m92@gmail.com wrote:

Hi

Given a text,say "hello elastic search world",
is there a way i can associate a field or some metadata per word in the
text on which i can later query?
for eg: give code number to each word, and should be able to search like
text = "hello" AND code = "25"
i.e return all "hello" words which have 25 in their code metadata.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f5f40059-e9e7-4a05-93f8-aacdff26abb0%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/f5f40059-e9e7-4a05-93f8-aacdff26abb0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAGdPd5nwzNDRVkkxJ8qczgzFAacatg-tEQYaAkrk%2BeHRRcqthA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(Neeraj Makam) #3

hi, thanks for the answer.
But that would stop me from enabling highlighting for such queries. Can you
think of any workaround for highlighting also to work?

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/ace6896e-bbd5-48d5-a4fa-bd9d4e6d7a0f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


(Jörg Prante) #4

There is a related feature that is called payloads for terms. In
Elasticsearch you can assign payload to terms, e.g. numbers for custom
scoring.

See also


It uses DelimitedPayloadTokenFilter

http://lucene.apache.org/core/4_7_0/analyzers-common/org/apache/lucene/analysis/payloads/DelimitedPayloadTokenFilter.html

Jörg

On Wed, Apr 30, 2014 at 1:06 PM, Neeraj Makam neeraj23m92@gmail.com wrote:

Hi

Given a text,say "hello elastic search world",
is there a way i can associate a field or some metadata per word in the
text on which i can later query?
for eg: give code number to each word, and should be able to search like
text = "hello" AND code = "25"
i.e return all "hello" words which have 25 in their code metadata.

--
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.
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/f5f40059-e9e7-4a05-93f8-aacdff26abb0%40googlegroups.comhttps://groups.google.com/d/msgid/elasticsearch/f5f40059-e9e7-4a05-93f8-aacdff26abb0%40googlegroups.com?utm_medium=email&utm_source=footer
.
For more options, visit https://groups.google.com/d/optout.

--
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.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/CAKdsXoEV56vGmxgKceY5dcSkEsJwEwrmtVXona-MH298YOExnQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


(system) #5