Hibernate Search 6返回结果,但解释值为0.0

问题描述

我正在尝试休眠搜索6,因为5对我来说很难使用。

但是当匹配的解释为0.0时,结果是否仍返回实体?

为什么0.0有时是这个

2020-09-15 21:57:43.107  INFO 18032 --- [nio-8080-exec-8] n.l.a.s.r.search.HibernateSearchService  : 0.0 = Failure to meet condition(s) of required/prohibited clause(s)
  0.0 = no match on required clause ((MatchNodocsQuery("empty BooleanQuery"))^4.0 description:amonsdu platform:amonsdu platformId:amonsdu)
    0.0 = No matching clauses
  0.0 = match on required clause,product of:
    0.0 = # clause
    1.0 = __HSEARCH_type:main

=>未作为结果返回

有时是这个吗?

2020-09-15 21:57:46.475  INFO 18032 --- [io-8080-exec-10] n.l.a.s.r.search.HibernateSearchService  : 0.0 = sum of:
  0.0 = sum of:
    0.0 = Constantscore(name:us)^0.0
  0.0 = match on required clause,product of:
    0.0 = # clause
    1.0 = __HSEARCH_type:main

=>作为结果返回

这是处理搜索代码

@Transactional
    public Page<Game> fuzzySearch(String searchTerm,Pageable pageable) {
        SearchSession searchSession = Search.session(entityManager);
        LucenesearchQuery<Game> gameSearchQuery = searchSession.search(Game.class)
                .extension(LuceneExtension.get())
                .where(f -> f.bool()
                        .should(
                                f.match()
                                        .field("name")
                                        .matching(searchTerm)
                                        .fuzzy(2,0)
                                        .boost(4)
                        ).should(
                                f.phrase()
                                        .field("description")
                                        .matching(searchTerm)
                                        .slop(3)
                                        .boost(1)
                        )
                        .should(
                                f.match()
                                        .fields("platform","platformId")
                                        .matching(searchTerm)
                        )

                ).toQuery();
        SearchResult<Game> result = gameSearchQuery.fetch((int) pageable.getoffset(),pageable.getPageSize());
        Explanation explanation = gameSearchQuery.explain(21L);
        log.info(explanation.toString());
        log.info(result.hits().toString());
        return new PageImpl<>(result.hits(),pageable,result.total().hitCount());
    }

正在搜索的实体

@Data
@MappedSuperclass
public class GameInfo {

    @FullTextField(analyzer = "gameName")
    @NotBlank
    @Size(min = 2,max = 500)
    private String name;

    @FullTextField(analyzer = "gameDescription")
    @Size(max = 6000)
    private String description;

    @KeywordField
    private String platform;

    @KeywordField
    private String platformId;


}

还有自定义分析器

 public void configure(LuceneAnalysisConfigurationContext context) {
            context.analyzer("gameName").custom()
                    .tokenizer(WhitespacetokenizerFactory.class)
                    .tokenFilter(LowerCaseFilterFactory.class);
            context.analyzer("gameDescription").custom()
                    .tokenizer(StandardTokenizerFactory.class)
                    .tokenFilter(LowerCaseFilterFactory.class)
                    .tokenFilter(snowballPorterFilterFactory.class)
                        .param("language","English");
    }

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

Selenium Web驱动程序和Java。元素在(x,y)点处不可单击。其...
Python-如何使用点“。” 访问字典成员?
Java 字符串是不可变的。到底是什么意思?
Java中的“ final”关键字如何工作?(我仍然可以修改对象。...
“loop:”在Java代码中。这是什么,为什么要编译?
java.lang.ClassNotFoundException:sun.jdbc.odbc.JdbcOdbc...