You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Jeffrey Chang <jc...@gmail.com> on 2011/05/27 05:09:53 UTC

highlighting in multiValued field

Hi All,

I am having a problem with search highlighting for multiValued fields and am
wondering if someone can point me in the right direction.

I have in my schema a multiValued field as such:
 <field name="description" type="text" stored="true" indexed="true"
multiValued="true"/>

When I search for term "Tel", it returns me the correct doc:
<doc>
...
<arr name="description">
  <str>Tel to talent 1</str>
  <str>Tel to talent 2</str>
  </arr>
...
</doc>

When I enable highlighting, it returns me the following highlight with only
one vector returned:
...
<lst name="highlighting">
  <lst name="1">
  <arr name="description">
    <str><em>Tel</em> to talent 1</str>
  </arr>
  </lst>
</lst>
What I'm expecting is actually both vectors to be returned as such:
<lst name="highlighting">
  <lst name="1">
  <arr name="description">
    <str><em>Tel</em> to talent 1</str>
    <str><em>Tel</em> to talent 2</str>
  </arr>
  </lst>
</lst>
Am I doing something wrong in my config or query (I'm using default)? Any
help is appreciated.

Thanks,
Jeff

Re: highlighting in multiValued field

Posted by Jeffrey Chang <jc...@gmail.com>.
Hi All,

I'll share my own workaround for my own issue.

I simply created a new multiValued field that concatenantes the multiValued
fields for index. During search, I will then have both fields in the same
array position.

Thanks,
Jeff

On Fri, May 27, 2011 at 10:24 PM, Jeffrey Chang <jc...@gmail.com> wrote:

> Hi Bob,
>
> Hmm... I don't think this approach will scale with bigger and more
> documents :(
>
> Thanks for your help though; I think I should take a look at customizing
> highlight component to achieve this...
>
> Thanks,
> Jeff
>
>
>
> On May 27, 2011, at 12:24 PM, Bob Sandiford <bo...@sirsidynix.com>
> wrote:
>
> > The only thing I can think of is to post-process your snippets.  I.E.
> pull the highlighting tags out of the strings, look for the match in your
> result "description" field looking for a match, and if you find one, replace
> that "description" with the original highlight text (i.e. with the highlight
> tags still in place).
> >
> > Bob Sandiford | Lead Software Engineer | SirsiDynix
> > P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> > www.sirsidynix.com
> > Join the conversation - you may even get an iPad or Nook out of it!
> >
> > Like us on Facebook!
> >
> > Follow us on Twitter!
> >
> >
> >
> >> -----Original Message-----
> >> From: Jeffrey Chang [mailto:jclalala@gmail.com]
> >> Sent: Friday, May 27, 2011 12:16 AM
> >> To: solr-user@lucene.apache.org
> >> Subject: Re: highlighting in multiValued field
> >>
> >> Hi Bob,
> >>
> >> I have no idea how I missed that! Thanks for pointing me to use
> >> hl.snippets
> >> - that did the magic!
> >>
> >> Please allow me squeeze one more question along the same line.
> >>
> >> Since I'm now able to display multiple snippets - what I'm trying to
> >> achieve
> >> is, determine which highlighted snippet maps back to what position in
> >> the
> >> original document.
> >>
> >> e.g. If I search for "Tel", with highlighting and hl.snippets=2 it'll
> >> return
> >> me:
> >> <doc>
> >> ...
> >> <arr name="descID">
> >>  <str>1</str>
> >>  <str>2</str>
> >>  <str>3</str>
> >> </arr>
> >> <arr name="description">
> >>  <str>Tel to talent 1</str>
> >>  <str>Tel to talent 2</str>
> >>  <str>Tel to talent 3</str>
> >> </arr>
> >> ...
> >> </doc>
> >> <lst name="highlighting">
> >>  <lst name="1">
> >>  <arr name="description">
> >>    <str><em>Tel</em> to talent 1</str>
> >>    <str><em>Tel</em> to talent 2</str>
> >>  </arr>
> >> </lst>
> >> ...
> >>
> >> Is there a way for me to figure out which highlighted snippet belongs
> >> to
> >> which descID so I can display also display the non-highlighted rows for
> >> my
> >> search results.
> >>
> >> Or is this not the way how highlighting is designed and to be used?
> >>
> >> Thanks so much,
> >> Jeff
> >> [snip]
> >
>

Re: highlighting in multiValued field

Posted by Jeffrey Chang <jc...@gmail.com>.
Hi Bob,

Hmm... I don't think this approach will scale with bigger and more documents :(

Thanks for your help though; I think I should take a look at customizing highlight component to achieve this...

Thanks,
Jeff



On May 27, 2011, at 12:24 PM, Bob Sandiford <bo...@sirsidynix.com> wrote:

> The only thing I can think of is to post-process your snippets.  I.E. pull the highlighting tags out of the strings, look for the match in your result "description" field looking for a match, and if you find one, replace that "description" with the original highlight text (i.e. with the highlight tags still in place).
> 
> Bob Sandiford | Lead Software Engineer | SirsiDynix
> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> www.sirsidynix.com 
> Join the conversation - you may even get an iPad or Nook out of it!
> 
> Like us on Facebook!
> 
> Follow us on Twitter!
> 
> 
> 
>> -----Original Message-----
>> From: Jeffrey Chang [mailto:jclalala@gmail.com]
>> Sent: Friday, May 27, 2011 12:16 AM
>> To: solr-user@lucene.apache.org
>> Subject: Re: highlighting in multiValued field
>> 
>> Hi Bob,
>> 
>> I have no idea how I missed that! Thanks for pointing me to use
>> hl.snippets
>> - that did the magic!
>> 
>> Please allow me squeeze one more question along the same line.
>> 
>> Since I'm now able to display multiple snippets - what I'm trying to
>> achieve
>> is, determine which highlighted snippet maps back to what position in
>> the
>> original document.
>> 
>> e.g. If I search for "Tel", with highlighting and hl.snippets=2 it'll
>> return
>> me:
>> <doc>
>> ...
>> <arr name="descID">
>>  <str>1</str>
>>  <str>2</str>
>>  <str>3</str>
>> </arr>
>> <arr name="description">
>>  <str>Tel to talent 1</str>
>>  <str>Tel to talent 2</str>
>>  <str>Tel to talent 3</str>
>> </arr>
>> ...
>> </doc>
>> <lst name="highlighting">
>>  <lst name="1">
>>  <arr name="description">
>>    <str><em>Tel</em> to talent 1</str>
>>    <str><em>Tel</em> to talent 2</str>
>>  </arr>
>> </lst>
>> ...
>> 
>> Is there a way for me to figure out which highlighted snippet belongs
>> to
>> which descID so I can display also display the non-highlighted rows for
>> my
>> search results.
>> 
>> Or is this not the way how highlighting is designed and to be used?
>> 
>> Thanks so much,
>> Jeff
>> [snip]
> 

RE: highlighting in multiValued field

Posted by Bob Sandiford <bo...@sirsidynix.com>.
The only thing I can think of is to post-process your snippets.  I.E. pull the highlighting tags out of the strings, look for the match in your result "description" field looking for a match, and if you find one, replace that "description" with the original highlight text (i.e. with the highlight tags still in place).

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com 
Join the conversation - you may even get an iPad or Nook out of it!

Like us on Facebook!

Follow us on Twitter!



> -----Original Message-----
> From: Jeffrey Chang [mailto:jclalala@gmail.com]
> Sent: Friday, May 27, 2011 12:16 AM
> To: solr-user@lucene.apache.org
> Subject: Re: highlighting in multiValued field
> 
> Hi Bob,
> 
> I have no idea how I missed that! Thanks for pointing me to use
> hl.snippets
> - that did the magic!
> 
> Please allow me squeeze one more question along the same line.
> 
> Since I'm now able to display multiple snippets - what I'm trying to
> achieve
> is, determine which highlighted snippet maps back to what position in
> the
> original document.
> 
> e.g. If I search for "Tel", with highlighting and hl.snippets=2 it'll
> return
> me:
> <doc>
> ...
> <arr name="descID">
>   <str>1</str>
>   <str>2</str>
>   <str>3</str>
> </arr>
> <arr name="description">
>   <str>Tel to talent 1</str>
>   <str>Tel to talent 2</str>
>   <str>Tel to talent 3</str>
> </arr>
> ...
> </doc>
> <lst name="highlighting">
>   <lst name="1">
>   <arr name="description">
>     <str><em>Tel</em> to talent 1</str>
>     <str><em>Tel</em> to talent 2</str>
>   </arr>
> </lst>
> ...
> 
> Is there a way for me to figure out which highlighted snippet belongs
> to
> which descID so I can display also display the non-highlighted rows for
> my
> search results.
> 
> Or is this not the way how highlighting is designed and to be used?
> 
> Thanks so much,
> Jeff
> [snip]


Re: highlighting in multiValued field

Posted by Jeffrey Chang <jc...@gmail.com>.
Hi Bob,

I have no idea how I missed that! Thanks for pointing me to use hl.snippets
- that did the magic!

Please allow me squeeze one more question along the same line.

Since I'm now able to display multiple snippets - what I'm trying to achieve
is, determine which highlighted snippet maps back to what position in the
original document.

e.g. If I search for "Tel", with highlighting and hl.snippets=2 it'll return
me:
<doc>
...
<arr name="descID">
  <str>1</str>
  <str>2</str>
  <str>3</str>
</arr>
<arr name="description">
  <str>Tel to talent 1</str>
  <str>Tel to talent 2</str>
  <str>Tel to talent 3</str>
</arr>
...
</doc>
<lst name="highlighting">
  <lst name="1">
  <arr name="description">
    <str><em>Tel</em> to talent 1</str>
    <str><em>Tel</em> to talent 2</str>
  </arr>
</lst>
...

Is there a way for me to figure out which highlighted snippet belongs to
which descID so I can display also display the non-highlighted rows for my
search results.

Or is this not the way how highlighting is designed and to be used?

Thanks so much,
Jeff

On Fri, May 27, 2011 at 11:33 AM, Bob Sandiford <
bob.sandiford@sirsidynix.com> wrote:

> What is your actual query?  Did you look at the "hl.snippets" parameter?
>
> Bob Sandiford | Lead Software Engineer | SirsiDynix
> P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
> www.sirsidynix.com
> Join the conversation - you may even get an iPad or Nook out of it!
>
> Like us on Facebook!
>
> Follow us on Twitter!
>
>
>
> > -----Original Message-----
> > From: Jeffrey Chang [mailto:jclalala@gmail.com]
> > Sent: Thursday, May 26, 2011 11:10 PM
> > To: solr-user@lucene.apache.org
> > Subject: highlighting in multiValued field
> >
> > Hi All,
> >
> > I am having a problem with search highlighting for multiValued fields
> > and am
> > wondering if someone can point me in the right direction.
> >
> > I have in my schema a multiValued field as such:
> >  <field name="description" type="text" stored="true" indexed="true"
> > multiValued="true"/>
> >
> > When I search for term "Tel", it returns me the correct doc:
> > <doc>
> > ...
> > <arr name="description">
> >   <str>Tel to talent 1</str>
> >   <str>Tel to talent 2</str>
> >   </arr>
> > ...
> > </doc>
> >
> > When I enable highlighting, it returns me the following highlight with
> > only
> > one vector returned:
> > ...
> > <lst name="highlighting">
> >   <lst name="1">
> >   <arr name="description">
> >     <str><em>Tel</em> to talent 1</str>
> >   </arr>
> >   </lst>
> > </lst>
> > What I'm expecting is actually both vectors to be returned as such:
> > <lst name="highlighting">
> >   <lst name="1">
> >   <arr name="description">
> >     <str><em>Tel</em> to talent 1</str>
> >     <str><em>Tel</em> to talent 2</str>
> >   </arr>
> >   </lst>
> > </lst>
> > Am I doing something wrong in my config or query (I'm using default)?
> > Any
> > help is appreciated.
> >
> > Thanks,
> > Jeff
>
>

RE: highlighting in multiValued field

Posted by Bob Sandiford <bo...@sirsidynix.com>.
What is your actual query?  Did you look at the "hl.snippets" parameter?

Bob Sandiford | Lead Software Engineer | SirsiDynix
P: 800.288.8020 X6943 | Bob.Sandiford@sirsidynix.com
www.sirsidynix.com 
Join the conversation - you may even get an iPad or Nook out of it!

Like us on Facebook!

Follow us on Twitter!



> -----Original Message-----
> From: Jeffrey Chang [mailto:jclalala@gmail.com]
> Sent: Thursday, May 26, 2011 11:10 PM
> To: solr-user@lucene.apache.org
> Subject: highlighting in multiValued field
> 
> Hi All,
> 
> I am having a problem with search highlighting for multiValued fields
> and am
> wondering if someone can point me in the right direction.
> 
> I have in my schema a multiValued field as such:
>  <field name="description" type="text" stored="true" indexed="true"
> multiValued="true"/>
> 
> When I search for term "Tel", it returns me the correct doc:
> <doc>
> ...
> <arr name="description">
>   <str>Tel to talent 1</str>
>   <str>Tel to talent 2</str>
>   </arr>
> ...
> </doc>
> 
> When I enable highlighting, it returns me the following highlight with
> only
> one vector returned:
> ...
> <lst name="highlighting">
>   <lst name="1">
>   <arr name="description">
>     <str><em>Tel</em> to talent 1</str>
>   </arr>
>   </lst>
> </lst>
> What I'm expecting is actually both vectors to be returned as such:
> <lst name="highlighting">
>   <lst name="1">
>   <arr name="description">
>     <str><em>Tel</em> to talent 1</str>
>     <str><em>Tel</em> to talent 2</str>
>   </arr>
>   </lst>
> </lst>
> Am I doing something wrong in my config or query (I'm using default)?
> Any
> help is appreciated.
> 
> Thanks,
> Jeff