[hibernate-issues] [Hibernate-JIRA] Commented: (HSEARCH-93) index map<String, Object>

koen handekyn (JIRA) noreply at atlassian.com
Fri Jul 6 09:58:52 EDT 2007


    [ http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-93?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel#action_27415 ] 

koen handekyn commented on HSEARCH-93:
--------------------------------------

i have implemented and tested the following MapBridge that stores a Map as key values to lucene

package upr.docstore.entity;

import java.util.Map;

import org.apache.lucene.document.Document;
import org.apache.lucene.document.Field;
import org.hibernate.search.bridge.FieldBridge;

public class MapBridge implements FieldBridge {

  public void set(String name, Object value, Document document, Field.Store store, Field.Index index, Float boost) {

    final Map<Object, Object> map = (Map<Object, Object>) value;

    for (final Map.Entry<Object, Object> entry : map.entrySet()) {

      if (entry.getValue() == null)
        continue;

      final String propertyName = entry.getKey().toString();
      final String propertyValue = entry.getValue().toString();

      final Field field = new Field(propertyName, propertyValue, store, index);

      if (boost != null)
        field.setBoost(boost);

      document.add(field);
    }

  }

}

> index map<String, Object>
> -------------------------
>
>                 Key: HSEARCH-93
>                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-93
>             Project: Hibernate Search
>          Issue Type: New Feature
>          Components: engine
>    Affects Versions: 3.0.0.beta3
>            Reporter: koen handekyn
>   Original Estimate: 1 day
>  Remaining Estimate: 1 day
>
> example class
> class MyDocument {
>   @DocumentId
>    long id;
>   @Fields
>   java.util.map<String, String> metaData;
> }
> the @Fields annotation stores each key value pair as a lucene key value.
> this allows efficient searching on loosely typed object meta data (which is typically hard to map onto a relational database model but perfect for a lucene index)
> note : this could probably be realized with a FieldBridge but a specifc annotaion could be handy
> note : ideally a MultiMap is also supported as a property can have multiple occurances in a lucene document

-- 
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators: http://opensource.atlassian.com/projects/hibernate/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira

        



More information about the hibernate-issues mailing list