我正在尝试使用lucene进行休眠搜索,但是由于我得到的搜索结果为空,因此索引编制工作无法正常进行。下面是配置。
Pom.xml
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-core</artifactId>
<version>5.3.7.Final</version>
</dependency>
<dependency>
<groupId>org.hibernate</groupId>
<artifactId>hibernate-search-orm</artifactId>
<version>5.10.4.Final</version>
</dependency>
<dependency>
<groupId>com.oracle</groupId>
<artifactId>ojdbc8</artifactId>
<version>12.2.0.1</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-core</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-aop</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-beans</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-expression</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-web</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-webmvc</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-tx</artifactId>
<version>${springframework.version}</version>
</dependency>
<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-orm</artifactId>
<version>${springframework.version}</version>
<exclusions>
<exclusion>
<artifactId>jboss-logging</artifactId>
<groupId>org.jboss.logging</groupId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.springframework.hateoas</groupId>
<artifactId>spring-hateoas</artifactId>
<version>0.23.0.RELEASE</version>
</dependency>
<dependency>
<groupId>org.springframework.data</groupId>
<artifactId>spring-data-jpa</artifactId>
<version>2.0.0.RELEASE</version>
<exclusions>
<exclusion>
<artifactId>org.hibernate</artifactId>
<groupId>hibernate-core</groupId>
</exclusion>
</exclusions>
</dependency>
下面是用于索引的Entity类配置-
@Indexed
public class Person
{
@Column(name = "V_FIRST_NAME")
@SortableField
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
private String firstName;
@Column(name = "V_MIDDLE_NAME")
@SortableField
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
private String middleName;
@Column(name = "V_LAST_NAME")
@SortableField
@Field(index = Index.YES, analyze = Analyze.YES, store = Store.NO)
private String lastName;
//setter/getter
}
休眠配置类
properties.setProperty("hibernate.search.default.directory_provider", "filesystem"); properties.setProperty("hibernate.search.default.indexBase","D:/SoftwaresConfigured/Lucene_Index/indexes"); properties.setProperty("hibernate.search.default.indexwriter.infostream", "true");
properties.setProperty("hibernate.search.default.exclusive_index_use","true");
properties.setProperty("hibernate.search.default.indexwriter.max_merge_docs","100");
properties.setProperty("hibernate.search.default.indexwriter.ram_buffer_size","64");
使用以下代码通过FullTextEntityManager创建索引
fullTextEntitymanager.createIndexer().batchSizeToLoadObjects(30)
.cacheMode(CacheMode.NORMAL).threadsToLoadObjects(10).startAndWait();
正在为少量数据创建索引文件,但对于大量数据却未创建索引文件。请帮忙。