Hi,
this my Entity bean classes are
Code:
@Indexed
public class TblAuthor implements Serializable
{
@Id
@DocumentId
private long authorid;
@Field(index=Index.TOKENIZED)
private String authorname;
@OneToMany
@IndexedEmbedded
private Set<TblBook> bookCollection;
}
@Indexed
public class TblBook implements Serializable
{
@Id
@DocumentId
private long bookid;
@Field(index=Index.TOKENIZED)
private String bookname;
@ManyToOne
private TblAuthor author;
}
persistence.xml
Code:
<!-- use a file system based index -->
<property name="hibernate.search.default.directory_provider"
value="org.hibernate.search.store.FSDirectoryProvider"/>
<!-- directory where the indexes will be stored -->
<property name="hibernate.search.default.indexBase"
value="/shoppingindia_index"/>
<property name="hibernate.ejb.event.post-insert"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-update"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
<property name="hibernate.ejb.event.post-delete"
value="org.hibernate.search.event.FullTextIndexEventListener"/>
Session bean class is
Code:
public class SearhAction implements Search,Serializable
{
@PersistenceContext(type=PersistenceContextType.EXTENDED)
private EntityManager em;
String queryString;
@Out(required=false)
List<TblAuthor> resultList;
public void doSearch ()
{
Map<String,Float> boostPerField = new HashMap<String,Float>();
boostPerField.put("authorname ", 4f);
boostPerField.put("bookCollection. bookname", 4f);
String[] productFields = {" authorname"bookCollection. bookname"};
QueryParser parser = new MultiFieldQueryParser(productFields, new StandardAnalyzer(), boostPerField);
parser.setAllowLeadingWildcard(true);
luceneQuery = parser.parse(queryString);
resultList=((FullTextEntityManager)em).createFullTextQuery(luceneQuery,TblAuthor.class).getResultList();
}
}
the seach function is working fine.
After update the primart table
Quote:
TblAuthor
index is triggerd.
but
i have issue when i update the seconday table value
Quote:
TblBook
the index is not triggered properly
i dont know how to resolve this problem
any help ...
By
Thiagu.m