How can I tell what matched?


(rbrc) #1

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field or
fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every single
field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of doing
this?


(David Pilato) #2

IMHO you will have to tell ES each field you want to highlight. Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednesday@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field or
fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every single
field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of doing
this?


(rbrc) #3

Any examples of that weirdness? Also I don't think that would work
well for multi document type searches...

On Apr 3, 3:02 pm, David Pilato da...@pilato.fr wrote:

IMHO you will have to tell ES each field you want to highlight. Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednes...@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field or
fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every single
field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of doing
this?


(David Pilato) #4

If you have a type A and a type B with fields A.a and B.a and B.b, you can
highlight "A.a" and "B.b" without highlighting "B.a". So you can "play" with
types and highlights as you want.

Is it your use case ?

BTW, highlighting is working fine also with multifields :
http://www.elasticsearch.org/guide/reference/mapping/multi-field-type.html

David

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de rbrc
Envoyé : mardi 3 avril 2012 21:44
À : elasticsearch
Objet : Re: how can I tell what matched?

Any examples of that weirdness? Also I don't think that would work
well for multi document type searches...

On Apr 3, 3:02 pm, David Pilato da...@pilato.fr wrote:

IMHO you will have to tell ES each field you want to highlight.
Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednes...@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field
or

fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every
single

field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of
doing this?


(rbrc) #5

I'm not quite sure yet how many doctypes we will have, but I'd bet at
least 3 and possibly as many as 10. In general, I'll want to search
across at least 3 of these at any given time. Most documents will
likely have an overlap of 2 fields, maybe 3.

On Apr 3, 7:05 pm, "David Pilato" da...@pilato.fr wrote:

If you have a type A and a type B with fields A.a and B.a and B.b, you can
highlight "A.a" and "B.b" without highlighting "B.a". So you can "play" with
types and highlights as you want.

Is it your use case ?

BTW, highlighting is working fine also with multifields :http://www.elasticsearch.org/guide/reference/mapping/multi-field-type...

David

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de rbrc
Envoyé : mardi 3 avril 2012 21:44
À : elasticsearch
Objet : Re: how can I tell what matched?

Any examples of that weirdness? Also I don't think that would work
well for multi document type searches...

On Apr 3, 3:02 pm, David Pilato da...@pilato.fr wrote:

IMHO you will have to tell ES each field you want to highlight.
Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednes...@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field
or

fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every
single

field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of
doing this?


(rbrc) #6

Thankfully I have schemas (via Mongoose as this is a nodejs/mongodb
project) for all of the indexed documents so I can pull the highlight
fields from those. I guess thats a workable solution.

On Apr 4, 9:56 am, rbrc wednes...@gmail.com wrote:

I'm not quite sure yet how many doctypes we will have, but I'd bet at
least 3 and possibly as many as 10. In general, I'll want to search
across at least 3 of these at any given time. Most documents will
likely have an overlap of 2 fields, maybe 3.

On Apr 3, 7:05 pm, "David Pilato" da...@pilato.fr wrote:

If you have a type A and a type B with fields A.a and B.a and B.b, you can
highlight "A.a" and "B.b" without highlighting "B.a". So you can "play" with
types and highlights as you want.

Is it your use case ?

BTW, highlighting is working fine also with multifields :http://www.elasticsearch.org/guide/reference/mapping/multi-field-type...

David

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de rbrc
Envoyé : mardi 3 avril 2012 21:44
À : elasticsearch
Objet : Re: how can I tell what matched?

Any examples of that weirdness? Also I don't think that would work
well for multi document type searches...

On Apr 3, 3:02 pm, David Pilato da...@pilato.fr wrote:

IMHO you will have to tell ES each field you want to highlight.
Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednes...@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field
or

fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every
single

field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of
doing this?


(rbrc) #7

And thank you for the help. :slight_smile:

On Apr 4, 10:40 am, rbrc wednes...@gmail.com wrote:

Thankfully I have schemas (via Mongoose as this is a nodejs/mongodb
project) for all of the indexed documents so I can pull the highlight
fields from those. I guess thats a workable solution.

On Apr 4, 9:56 am, rbrc wednes...@gmail.com wrote:

I'm not quite sure yet how many doctypes we will have, but I'd bet at
least 3 and possibly as many as 10. In general, I'll want to search
across at least 3 of these at any given time. Most documents will
likely have an overlap of 2 fields, maybe 3.

On Apr 3, 7:05 pm, "David Pilato" da...@pilato.fr wrote:

If you have a type A and a type B with fields A.a and B.a and B.b, you can
highlight "A.a" and "B.b" without highlighting "B.a". So you can "play" with
types and highlights as you want.

Is it your use case ?

BTW, highlighting is working fine also with multifields :http://www.elasticsearch.org/guide/reference/mapping/multi-field-type...

David

-----Message d'origine-----
De : elasticsearch@googlegroups.com
[mailto:elasticsearch@googlegroups.com] De la part de rbrc
Envoyé : mardi 3 avril 2012 21:44
À : elasticsearch
Objet : Re: how can I tell what matched?

Any examples of that weirdness? Also I don't think that would work
well for multi document type searches...

On Apr 3, 3:02 pm, David Pilato da...@pilato.fr wrote:

IMHO you will have to tell ES each field you want to highlight.
Highlighting _all can give strange results.

David :wink:
Twitter : @dadoonet / @elasticsearchfr

Le 3 avr. 2012 à 19:47, rbrc wednes...@gmail.com a écrit :

If I have a document that has many fields and I do a generic search
on, say, "foo", then I'd like to be able to highlight which field
or

fields matched "foo" so that I can highlight that for the user. So
far it seems that my choices are to store the _all field, which is
unwise (and I can't seem to get it working), or to name every
single

field in the the highlight section of the query, which
seems...inelegant, to say the least. Is there some other way of
doing this?


(system) #8