小编San*_*nne的帖子

Lucene:找到所有以特定前缀开头的单词

我想获得Lucene索引中以特定前缀开头的所有单词的列表.我一直在寻找一种方法来查询索引中的术语(我需要术语,我不关心它们来自哪些文档),但没有成功.有任何想法吗?

lucene search hibernate hibernate-search

2
推荐指数
1
解决办法
1144
查看次数

可以在没有科学记数法的情况下格式化Double吗?

我知道有关同一问题的各种帖子.

挖掘它有点不同,它可能有点明显,但我需要你的意见.

我目前正在使用Hibernate SearchLucene来索引实体属性.

我的实体上有一堆Double属性.

使用Lucene的默认桥接器(Bridge,即负责转换LongToStringStringToLong的桥接器)的这些实体在科学符号开始使用后给我带来麻烦.

我试图在DataTables上展示一个.xhtml信用卡和借记卡金额,它们的长度可以长达18位,其数据库(DB2)类型是BIGINT.

  1. 例如,我无法将DataBase类型更改为Long.
  2. 我不能将我的实体的Double类型属性更改为例如Long

那么问题是什么? 是否有一种方法从字符串说"1234567890"来检索格式为1234567890而不是1.23456789E9的Double,因为它默认情况下正在执行Double.parseDouble(FormattedString)

PD:我知道DecimalFormat的存在,但考虑到使用这个formater会给我一个正确格式化的字符串说:"#######.E0"但我真正需要的是具有这种格式的Double,但是在做的时候Double.parseDouble(FormattedString)我会放松这种格式.

希望我很清楚,谢谢你的帮助.

java string double hibernate-search

2
推荐指数
1
解决办法
1万
查看次数

如何在hibernate全文搜索中获得总计数?

我正在尝试通过以下链接使用hibernate全文: hibernate/search/4.1/reference/en-US/html/getting-started

基本上,它可以工作,但我想知道如何在执行全文查询时获得总计数,然后我可以告诉用户在这样的查询中将有多少结果和多少页面.

这是代码(使用JPA创建和执行搜索):

EntityManager em = entityManagerFactory.createEntityManager();
FullTextEntityManager fullTextEntityManager = 
org.hibernate.search.jpa.Search.getFullTextEntityManager(em);
em.getTransaction().begin();

// create native Lucene query unsing the query DSL
// alternatively you can write the Lucene query using the Lucene query parser
// or the Lucene programmatic API. The Hibernate Search DSL is recommended though
QueryBuilder qb = fullTextEntityManager.getSearchFactory()
    .buildQueryBuilder().forEntity( Book.class ).get();
org.apache.lucene.search.Query query = qb
  .keyword()
  .onFields("title", "subtitle", "authors.name", "publicationDate")
  .matching("Java rocks!")
  .createQuery();

// wrap Lucene query in a javax.persistence.Query
javax.persistence.Query persistenceQuery = 
    fullTextEntityManager.createFullTextQuery(query, Book.class);
 persistenceQuery.setFirstResult((page …
Run Code Online (Sandbox Code Playgroud)

spring full-text-search hibernate hibernate-search

2
推荐指数
1
解决办法
4658
查看次数

Hibernate Search可以通过用户可访问性来限制结果吗?

我正在使用Hibernate。我正在寻找一个自由文本引擎。

在进行调查之前,我需要您的经验。

我的应用程序中有用户,角色和对象表。用户连接到一个或多个角色,而角色连接到一个或多个对象的地方。

在我的自由文本搜索中,用户只能访问对象表允许他观看的数据。

Hibernate搜索可以帮助我吗?

java hibernate hibernate-search

1
推荐指数
1
解决办法
816
查看次数

如何获取lucene中的文档总数

我的索引中有非常多的文档,我需要编写一个返回lucence索引中文档总数的方法.目前我使用*通配符来获取所有记录并返回totalHits的值.

问题是,当查询加载所有对象时,它需要花费很多时间,虽然我不需要加载对象,但我的要求是在不加载文档的情况下获取记录总数.

java lucene spring hibernate hibernate-search

1
推荐指数
1
解决办法
3270
查看次数

如果我索引相同的数据,为什么lucene索引的大小会增加?

我在我的应用程序中实现了Hibernate Search,即基于Lucene.每当我对数据库编制索引时,lucene索引的大小就会增加.但是,查询的结果每次都返回相同的结果.

如果我每次都索引相同的数据,为什么每次都会增加lucene的大小?

FullTextSession fullTextSession = Search.getFullTextSession(getSession());
    org.hibernate.Transaction tx = fullTextSession.beginTransaction();

    Criteria criteria = fullTextSession.createCriteria(getPersistentClass())
    .setResultTransformer(CriteriaSpecification.DISTINCT_ROOT_ENTITY)
    .setCacheMode(CacheMode.IGNORE)
    .setFetchSize(pageSize)
    .setFlushMode(FlushMode.MANUAL);


    int i = 0;
    List<ProdAttrAssociationVO> results = null;
    do {
      criteria = criteria.setFirstResult(i)
        .setMaxResults(pageSize);
      results = criteria.list();

      for (ProdAttrAssociationVO entity : results) {
        fullTextSession.delete(entity);
        fullTextSession.index(entity);
      }

      // flush the index changes to disk so we don't hold until a commit
      if (i % batchSize == 0) {
        fullTextSession.flushToIndexes();
        fullTextSession.clear();
      }

      i += pageSize;
    } while (results.size() > 0);


    System.out.println("ProdAttrAssociation Indexing Completed"); …
Run Code Online (Sandbox Code Playgroud)

lucene indexing search hibernate hibernate-search

0
推荐指数
1
解决办法
819
查看次数

如何在JBoss7.1中使用Infinispan查询

我有一个通过JBoss7.1 Web界面创建的Infinispan缓存.它被配置为索引的分布式缓存.

在我的jboss-deployment-structure.xml文件中,我添加了依赖项org.infinispan,org.hibernate因此我可以访问我的缓存.我还在以下内容中添加了maven依赖项:

  <dependency>
     <groupId>org.infinispan</groupId>
     <artifactId>infinispan-core</artifactId>
     <version>5.1.7.Final</version>
     <scope>provided</scope>
  </dependency>
  <dependency>
     <groupId>org.infinispan</groupId>
     <artifactId>infinispan-query</artifactId>
     <version>5.1.7.Final</version>
  </dependency>
Run Code Online (Sandbox Code Playgroud)

5.1.7.Final是我正在使用的JBoss7.1.3中的org.infinispan模块中包含的版本.这将引入所有必需的依赖项(包括lucenehibernate-search-engine),因此我在项目中拥有必要的库.但是,在执行此处提到的初始步骤时:

  SearchManager searchManager = Search.getSearchManager( cache );
Run Code Online (Sandbox Code Playgroud)

它调用ComponentRegistryUtils.getComponent(cache, SearchFactoryIntegrator.class)失败抛出IllegalArgumentException:

此缓存未启用索引.接口org.hibernate.search.spi.SearchFactoryIntegrator在注册表中找不到

我的缓存启用了索引,cache.getCacheConfiguration().indexing().enabled()返回时可以看到true.但应用程序认为不是.也许这是因为缓存ComponentRegistry不能访问org.hibernate.search.spi.SearchFactoryIntegrator类(缓存是JBoss全局组件,而hibernate搜索lib在我的WAR WEB-INF/lib目录中).

还有另一种方法我应该这样做吗?

java lucene hibernate-search infinispan jboss7.x

0
推荐指数
1
解决办法
2483
查看次数