[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-185) Add selective property embedding in @IndexedEmbedded

Stephane Epardaud (JIRA) noreply at atlassian.com
Tue Apr 22 11:38:33 EDT 2008


Add selective property embedding in @IndexedEmbedded
----------------------------------------------------

                 Key: HSEARCH-185
                 URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-185
             Project: Hibernate Search
          Issue Type: New Feature
          Components: mapping
    Affects Versions: 3.0.1.GA
            Reporter: Stephane Epardaud
            Priority: Minor


We use @IndexedEmbedded for two reasons:

- Filtering entities based on some embedded entity fields in a HS filter
- Searching through the "text" field of every entity embedded in a root entity

If we could specify the fields that we embed we would not need to embed a whole entity in the index. For instance we don't need to embed its ID in most cases, or fields which might be useful for one embedding and not another one.

If we could add the following to the @IndexedEmbedded annotation:

 String[] fields() default {};

We could achieve the desired goal. An empty value would mean "embed all the fields" (this is still subject to depth), while a non-empty value would mean "only embed those fields" (still subject to depth).

This would be ideal in our current case if combined with @IndexedEmbeddeds: in our example, we have an Order entity which has several "actors" such as _buyer_ and _seller_. We need to embed the keys of those actors in the Order index in order to use them from our HS filter. We also have several "text" fields in Order and there are some in Person which we'd like to embed:

{code}
@Indexed
@Entity
public void Order implements Serializable {
 ...
 @IndexedEmbeddeds({
  // this is used by the filter for security
  @IndexedEmbedded(prefix="contacts.", fields={"key"}, depth=1),
  // this is for full-text search
  @IndexedEmbedded(prefix="", fields={"text"}, depth=1)
 })
 private Person buyer;

 @IndexedEmbeddeds({
  // this is used by the filter for security
  @IndexedEmbedded(prefix="contacts.", fields={"key"}, depth=1),
  // this is for full-text search
  @IndexedEmbedded(prefix="", fields={"text"}, depth=1)
 })
 private Person seller;

 @Field(name = "text", index = Index.TOKENIZED)
 private String description;

 ...
}

@Indexed
@Entity
public class Person implements Serializable {
 ...
 @Fields({
  // this is for full-text search
  @Field(name = "text"), 
  // this is for security checks in the filters
  @Field(name = "key", index = Index.UN_TOKENIZED, store = Store.YES)
 )}
 private String key;

 @Field(name = "text", index = Index.TOKENIZED)
 private String name;
}
{code}

What do you think?

This is a real-world requirement, and I don't think it should be too difficult to implement so if you agree with its usefulness I'm ready to back it up with a patch.

-- 
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