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 Avlesh Singh <av...@gmail.com> on 2009/10/04 17:07:29 UTC

Highlighting bean properties using DocumentObjectBinder - New feature?

Like most others, I use SolrJ and bind my beans with @Field annotations to
read responses from Solr.
For highlighting these properties in my bean, I always write a separate
piece - Get the list of highlights from response and then use the
Map<fieldName, List<highlights>> to put them back in my original bean.

This evening, I tried creating an @Highlight annotation and modified the
DocumentObjectBinder to understand this attribute (with a bunch of other
properties).

This is how it works:
You can annotate your beans with @Highlight as underneath.

class MyBean{
  @Field
  @Highlight
  String name;

  @Field ("solr_category_field_name")
  List<String> categories;

  @Highlight ("solr_category_field_name")
  List<String> highlightedCategories

  @Field
  float score;

  ...
}

and use QueryResponse#getBeans(MyBean.class) to achieve both - object
binding as well as highlighting.
I was wondering if this can be of help to most users or not. Can this be a
possible enhancement in DocumentObjectBinder? If yes, I can write a patch.

Cheers
Avlesh

Re: Highlighting bean properties using DocumentObjectBinder - New feature?

Posted by Avlesh Singh <av...@gmail.com>.
Sure!

Cheers
Avlesh

2009/10/6 Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>

> go ahead but mark for 1.5
>
> On Tue, Oct 6, 2009 at 4:50 PM, Avlesh Singh <av...@gmail.com> wrote:
> > Does this one deserve a JIRA issue?
> >
> > Cheers
> > Avlesh
> >
> > On Sun, Oct 4, 2009 at 8:37 PM, Avlesh Singh <av...@gmail.com> wrote:
> >
> >> Like most others, I use SolrJ and bind my beans with @Field annotations
> to
> >> read responses from Solr.
> >> For highlighting these properties in my bean, I always write a separate
> >> piece - Get the list of highlights from response and then use the
> >> Map<fieldName, List<highlights>> to put them back in my original bean.
> >>
> >> This evening, I tried creating an @Highlight annotation and modified the
> >> DocumentObjectBinder to understand this attribute (with a bunch of other
> >> properties).
> >>
> >> This is how it works:
> >> You can annotate your beans with @Highlight as underneath.
> >>
> >> class MyBean{
> >>   @Field
> >>   @Highlight
> >>   String name;
> >>
> >>   @Field ("solr_category_field_name")
> >>   List<String> categories;
> >>
> >>   @Highlight ("solr_category_field_name")
> >>   List<String> highlightedCategories
> >>
> >>   @Field
> >>   float score;
> >>
> >>   ...
> >> }
> >>
> >> and use QueryResponse#getBeans(MyBean.class) to achieve both - object
> >> binding as well as highlighting.
> >> I was wondering if this can be of help to most users or not. Can this be
> a
> >> possible enhancement in DocumentObjectBinder? If yes, I can write a
> patch.
> >>
> >> Cheers
> >> Avlesh
> >>
> >
>
>
>
> --
> -----------------------------------------------------
> Noble Paul | Principal Engineer| AOL | http://aol.com
>

Re: Highlighting bean properties using DocumentObjectBinder - New feature?

Posted by Noble Paul നോബിള്‍ नोब्ळ् <no...@corp.aol.com>.
go ahead but mark for 1.5

On Tue, Oct 6, 2009 at 4:50 PM, Avlesh Singh <av...@gmail.com> wrote:
> Does this one deserve a JIRA issue?
>
> Cheers
> Avlesh
>
> On Sun, Oct 4, 2009 at 8:37 PM, Avlesh Singh <av...@gmail.com> wrote:
>
>> Like most others, I use SolrJ and bind my beans with @Field annotations to
>> read responses from Solr.
>> For highlighting these properties in my bean, I always write a separate
>> piece - Get the list of highlights from response and then use the
>> Map<fieldName, List<highlights>> to put them back in my original bean.
>>
>> This evening, I tried creating an @Highlight annotation and modified the
>> DocumentObjectBinder to understand this attribute (with a bunch of other
>> properties).
>>
>> This is how it works:
>> You can annotate your beans with @Highlight as underneath.
>>
>> class MyBean{
>>   @Field
>>   @Highlight
>>   String name;
>>
>>   @Field ("solr_category_field_name")
>>   List<String> categories;
>>
>>   @Highlight ("solr_category_field_name")
>>   List<String> highlightedCategories
>>
>>   @Field
>>   float score;
>>
>>   ...
>> }
>>
>> and use QueryResponse#getBeans(MyBean.class) to achieve both - object
>> binding as well as highlighting.
>> I was wondering if this can be of help to most users or not. Can this be a
>> possible enhancement in DocumentObjectBinder? If yes, I can write a patch.
>>
>> Cheers
>> Avlesh
>>
>



-- 
-----------------------------------------------------
Noble Paul | Principal Engineer| AOL | http://aol.com

Re: Highlighting bean properties using DocumentObjectBinder - New feature?

Posted by Avlesh Singh <av...@gmail.com>.
Does this one deserve a JIRA issue?

Cheers
Avlesh

On Sun, Oct 4, 2009 at 8:37 PM, Avlesh Singh <av...@gmail.com> wrote:

> Like most others, I use SolrJ and bind my beans with @Field annotations to
> read responses from Solr.
> For highlighting these properties in my bean, I always write a separate
> piece - Get the list of highlights from response and then use the
> Map<fieldName, List<highlights>> to put them back in my original bean.
>
> This evening, I tried creating an @Highlight annotation and modified the
> DocumentObjectBinder to understand this attribute (with a bunch of other
> properties).
>
> This is how it works:
> You can annotate your beans with @Highlight as underneath.
>
> class MyBean{
>   @Field
>   @Highlight
>   String name;
>
>   @Field ("solr_category_field_name")
>   List<String> categories;
>
>   @Highlight ("solr_category_field_name")
>   List<String> highlightedCategories
>
>   @Field
>   float score;
>
>   ...
> }
>
> and use QueryResponse#getBeans(MyBean.class) to achieve both - object
> binding as well as highlighting.
> I was wondering if this can be of help to most users or not. Can this be a
> possible enhancement in DocumentObjectBinder? If yes, I can write a patch.
>
> Cheers
> Avlesh
>