search - 如何用 Solr 搜索汉字?
问题描述
基本上我正在研究 Drupal 并使用 Solr 作为搜索引擎。它搜索一些简体中文单词/字符和一些不像下面的
为美朝朝朝同盟进行的美国取得进展
它不是简单的字符搜索。
所以我经历了两个
https://lucene.apache.org/solr/guide/7_4/language-analysis.html http://www.opencms-wiki.org/wiki/Solr_-_configuration_for_Chinese_and_correct_results_for_german_umlauts
& 在我下面的 solr 配置文件中
<fieldType name="text_chinese" class="solr.TextField">
<analyzer class="org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer"/>
<analyzer>
<tokenizer class="solr.HMMChineseTokenizerFactory"/>
<filter class="solr.CJKWidthFilterFactory"/>
<filter class="solr.StopFilterFactory"
words="org/apache/lucene/analysis/cn/smart/stopwords.txt"/>
<filter class="solr.PorterStemFilterFactory"/>
<filter class="solr.LowerCaseFilterFactory"/>
</analyzer>
</fieldType>
它在给
本地:org.apache.solr.common.SolrException:org.apache.solr.common.SolrException:无法为核心本地加载conf:[schema.xml]字段类型“text_chinese”的插件初始化失败:无法加载分析器:org。 apache.lucene.analysis.cn.smart.SmartChineseAnalyzer。架构文件是 /var/solr/cores/local/conf/schema.xml
仍然没有给出结果。
不确定是否缺少配置中的某些内容。
解决方案
The error message is telling you that Solr isn't able to find the implementing class of the analyzer you have defined - Cannot load analyzer: org.apache.lucene.analysis.cn.smart.SmartChineseAnalyzer
.
The SmartCN analyzer isn't loaded by default, but it's included in the binary build under contrib/analysis-extras/lucene-libs/lucene-analyzers-smartcn-<version number>.jar
.
Add the directory to the list of directories that Solr can load libraries from in solrconfig.xml:
<lib dir="../../../contrib/analysis-extras/lucene-libs" regex=".*smartcn.*\.jar" />
推荐阅读
- python - Flask中使用的SQLAlchemy,Session管理实现
- r - 从一组行中随机选择一个值并将值添加到下面的新行
- google-data-studio - Data Studio API - 列出组织的所有报告
- typescript - vscode调试typescript导致js文件
- c++ - 错误:没有匹配的函数来调用修复
- apache-spark - 循环通过 rdd.collect() 时创建新的 Spark DataFrame
- firewall - 新的 Windows netsh 防火墙规则是否会中断现有连接?
- java - Android / Java WebView Fileupload 在 Android 版本 10 和 11 中失败
- java - 目标箭头 在 Android Studio Java 中为初次使用的用户突出显示
- javascript - D3.js 版本 6:加载 CSV 并更改变量类型