[hibernate-issues] [Hibernate-JIRA] Created: (HSEARCH-26) @Field( groups=... )

Sylvain Vieujot (JIRA) noreply at atlassian.com
Tue Mar 6 18:10:32 EST 2007


@Field( groups=... )
--------------------

         Key: HSEARCH-26
         URL: http://opensource.atlassian.com/projects/hibernate/browse/HSEARCH-26
     Project: Hibernate Search
        Type: New Feature

  Components: query  
    Versions: FIRST    
    Reporter: Sylvain Vieujot


To search on multiple fields, one ugly solution is to concatenate all the entity's searchable fields in a big text that is indexed.

A cleaner solution is to use an org.apache.lucene.queryParser.MultiFieldQueryParser
This parser requires a String[] of the fields to search on.
To avoid having to give this (long) list of files to every query, and to have to manage it by hand, the idea is to have field "groups".
So you could add a parameter to the @Field annotation as in this example :

@Entity
@Indexed
public CV {

@Field( Indexed.TOKENIZED, queryGroups={"all"} )
String name;

@Field( Indexed.TOKENIZED, queryGroups={"accounting"} )
String bankAccount;

@Field( Indexed.TOKENIZED, queryGroups={"accounting","backOffice"} )
String address;

@SearchableEmbeddeable( queryGroups={"accounting","backOffice"} )
MedicalInfo mi;
}

Those groups could be used like security roles in servlets.
In the above examples, you could ask for the list of searchable fields for the accountants :

String[] searchableFieldsForAccountants = ContextHelper( session ).getDocumentBuilder( CV.class ).getFieldsForGroup( "accountants" );

Then you could construct the query parser :
luceneQuery = new MultiFieldQueryParser( searchableFieldsForAccountants getAnalyzer() );


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