I have two Classes.
public Class Student
{
//primary key
private String id;
private String name;//name = Jonathan
....
private List<CustomField> customFields;
}
public Class CustomField
{
//primary key
private String id;
private String fieldName;
....
private String fieldValue;
}
customFields are defined by user, can be any fields and values.For example: there are two objects in customFields list. they are [id = 001,fieldName = age,value = 30] [id=002,fieldName = score,value = 90]. (Also user can add/update some necessary field in the customFields list,the customFields is dynamic)
So if the class 'Student' send to my web page , it will display:Name:[Jonathan] Age:[30] Score:[90] on web page.
User case: user can search by the fields that's Name,Age and Score. So those fields should be indexed into Lucene Document. If indexing the custom field useing Hibernate search , how do i write the indexing annotation for the dynamic field?
So I need to index and search the dynamic customFields using Hibernate Search,Ho can i implelement it? Do you know what i mean?
Edit:
public class CustomFieldBriddge implements FieldBridge
{
public void set(String name, Object value, Document document, LuceneOptions luceneOptions)
{
Field.Store store = luceneOptions.getStore();
Field.Index index = luceneOptions.getIndex();
Field.TermVector termVector = luceneOptions.getTermVector();
Float boost = luceneOptions.getBoost();
if (value != null)
{
List<CustomField> customFields = (List) value;
for (CustomField customField : customFields)
{
String fieldName = customField.getFiledName();
String fieldValue = customField.getFiledValue();
Field field = new Field(fieldName, fieldValue, store.YES, index.NOT_ANALYZED,
termVector); // is the field will index into Lucene document one by one?and it can be searched out? right?
field.setBoost(boost);
document.add(field); // is this operation will index the field into Lucuene Document?
}
}
}