0

您好有以下搜索词组

2012 日产 gtr 黑色

我试图创建一个关键字搜索,该搜索将返回该索引,其中包含以任何顺序输入的关键短语。

例子

“黑色 gtr”或“2012 gtr black”等。

我使用以下建议指南,但似乎无法弄清楚如何让搜索以任何顺序搜索索引。我尝试了关键字,但这似乎返回了其他索引。

Query query = title.phrase().withSlop(2)
             .onField (TITLE_NGRAM_INDEX)
             .andField(TITLE_EDGE_NGRAM_INDEX).boostedTo(5)
             .sentence(searchTerm.toLowerCase()).createQuery();

FullTextQuery fullTextQuery = getFullTextSession()
.createFullTextQuery(query, Product.class);   

fullTextQuery.setMaxResults(20);

http://n-chandra.blogspot.com/2013/09/hibernate-search-based-autocomplete.html?m=1

有人知道如何让它工作吗?

4

0 回答 0