lucene-solr-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Avlesh Singh <avl...@gmail.com>
Subject Highlighting bean properties using DocumentObjectBinder - New feature?
Date Sun, 04 Oct 2009 15:07:29 GMT
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

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message