Hi,
new to this text search thing and need some help.
Have JPA implementation for my datastore and would like to add text searching to it.
Got latest jars as required and all properties are included in my persitance.xml. When I try to create index I just get two segmented files. I am including my config files and method how I am going after creating index. I suspect indexing is being interrupted but not sure why. Maybe there is something totally obvious I am missing here.Any help would be appreciated.
persistence.xml
<persistence xmlns="http://java.sun.com/xml/ns/persistence"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/persistence http://java.sun.com/xml/ns/persistence/ ... ce_1_0.xsd"
version="1.0">
<!-- persistence-unit name="punit" -->
<persistence-unit name="testPU"
<properties>
<property name="hibernate.show_sql" value="true" />
<property name="hibernate.hbm2ddl.auto" value="create-drop" />
<property name="hibernate.connection.driver_class"
value="com.mysql.jdbc.Driver" />
<property name="hibernate.connection.url"
value="jdbc:mysql://localhost/db" />
<property name="hibernate.connection.username" value="dd" />
<property name="hibernate.connection.password"
value="dd" />
<property name="hibernate.search.default.directory_provider"
value="org.hibernate.search.store.FSDirectoryProvider" />
<property name="hibernate.search.default.indexBase"
value="c:\\work\\temp\\lucene\\indexes" />
<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" />
</properties>
</persistence-unit>
</persistence>
this how I create index:
public void createIndex() {
System.out.println("createIndex");
EntityManager em = getEntityManager();
FullTextEntityManager fullTextEntityManager = Search
.createFullTextEntityManager(em);
List<Author> authors = em.createQuery("select p FROM Author p")
.getResultList();
for (Author author : authors) {
System.out.println("authors : " + author.getAuthorName());
}
System.out.println(" Result : " + authors.size());
"I get here correct number of records from BD"
for (Author author : authors) {
fullTextEntityManager.index(authors);
}
}