gpt4 book ai didi

SOLR - 自动建议短语

转载 作者:行者123 更新时间:2023-12-05 00:53:13 25 4
gpt4 key购买 nike

我正在使用 SOLR 建议器组件,但我不知道如何阻止它在空格上拆分并为每个单词返回多个建议。

我想发出命令: http://localhost:8983/solr/suggest?q= “内存泄漏”

并让它在我的搜索字段(使用 KeywordTokenizerFactory 而不是 StandardTokenizerFactory 创建)中搜索整个短语。

我肯定只是在装傻?

最佳答案

看看这个线程: http://lucene.472066.n3.nabble.com/suggester-issues-td3262718.html

您可能必须使用如下所示的自定义类才能获得您期望的结果:

import java.util.ArrayList; 
import java.util.Collection;
import java.util.Collections;

import org.apache.lucene.analysis.Token;
import org.apache.solr.spelling.QueryConverter;

/**
* Converts the query string to a Collection of Lucene tokens.
**/
public class SpellingQueryConverter extends QueryConverter {

/**
* Converts the original query string to a collection of Lucene Tokens.
* @param original the original query string
* @return a Collection of Lucene Tokens
*/
@Override
public Collection<Token> convert(String original) {
if (original == null) {
return Collections.emptyList();
}
Collection<Token> result = new ArrayList<Token>();
Token token = new Token(original, 0, original.length(), "word");
result.add(token);
return result;
}

}

关于SOLR - 自动建议短语,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7766577/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com