0

我发现它支持很多语言,但支持中文。

更新 我可以使用 Luke 搜索我的数据,请看截图 在此处输入图像描述 试过这个:添加

    <fieldType name="text_chinese" class="solr.TextField">
         <analyzer type="index">
        <tokenizer class="solr.CJKTokenizerFactory"/>
        </analyzer>
    </fieldType>

到schema.xml,也试过

   <fieldType name="text_chinese" class="solr.TextField">
      <analyzer class="org.apache.lucene.analysis.cn.ChineseAnalyzer"/>
   </fieldType>

 <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.CJKTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.StandardTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.SynonymFilterFactory" synonyms="synonyms.txt" ignoreCase="true" expand="true"/>
    <filter class="solr.LowerCaseFilterFactory"/>
  </analyzer>
</fieldType>

但这些都不起作用。我想知道“ <fieldType name=”的格式到底是什么,是text_chinese还是text_cn还是text_zh_cn?但我已经尝试过所有这些格式。

顺便说一句,我可以使用 engnlish 属性搜索我的文档。而且我无法通过在我的网络浏览器 UI 中输入“name:something”进行搜索,我遇到了异常:

org.springframework.dao.InvalidDataAccessApiUsageException: Bad Request

Bad Request

request: http://localhost:8180/solr/select?q=name:*name:something* or description:*name:something* or type:*name:something* or mac_address:*name:something* or uri:*name:something* or attrs:*name:something*&start=0&rows=0&wt=javabin&version=2; nested exception is org.apache.solr.common.SolrException: Bad Request

Bad Request

request: http://localhost:8180/solr/select?q=name:*name:something* or description:*name:something* or type:*name:something* or mac_address:*name:something* or uri:*name:something* or attrs:*name:something*&start=0&rows=0&wt=javabin&version=2
    at org.springframework.data.solr.core.SolrExceptionTranslator.translateExceptionIfPossible(SolrExceptionTranslator.java:58)
    at org.springframework.data.solr.core.SolrTemplate.execute(SolrTemplate.java:106)
    at org.springframework.data.solr.core.SolrTemplate.count(SolrTemplate.java:126)
    at org.springframework.data.solr.repository.query.AbstractSolrQuery$CollectionExecution.count(AbstractSolrQuery.java:92)
    at org.springframework.data.solr.repository.query.AbstractSolrQuery$CollectionExecution.execute(AbstractSolrQuery.java:87)
    at org.springframework.data.solr.repository.query.AbstractSolrQuery.execute(AbstractSolrQuery.java:52)
    at org.springframework.data.repository.core.support.RepositoryFactorySupport$QueryExecutorMethodInterceptor.invoke(RepositoryFactorySupport.java:313)
    at org.springframework.aop.framework.ReflectiveMethodInvocation.proceed(ReflectiveMethodInvocation.java:172)
    at org.springframework.aop.framework.JdkDynamicAopProxy.invoke(JdkDynamicAopProxy.java:202)

这是春季数据解决方案错误吗?

4

2 回答 2

0

SmartChineseAnalyzer似乎做了一个典型的分析器实现来索引中文文本。

smartcn API中提供了更多工具,CJKTokenizer是一个很好的中文分词器(以及日文和韩文,因此得名)。

于 2013-04-10T03:51:13.850 回答
0
<fieldType name="wc_text" class="solr.TextField" positionIncrementGap="100">
  <analyzer type="index">
    <tokenizer class="solr.ChineseTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="1" catenateNumbers="1" catenateAll="0" splitOnCaseChange="0" preserveOriginal="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>

    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
  <analyzer type="query">
    <tokenizer class="solr.ChineseTokenizerFactory"/>
    <filter class="solr.StopFilterFactory" ignoreCase="true" words="stopwords.txt" enablePositionIncrements="true" />
    <filter class="solr.WordDelimiterFilterFactory" generateWordParts="1" generateNumberParts="1" catenateWords="0" catenateNumbers="0" catenateAll="0" splitOnCaseChange="0" preserveOriginal="1"/>
    <filter class="solr.LowerCaseFilterFactory"/>
    <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
  </analyzer>
</fieldType

对中文字符使用上述过滤器工厂,并在应用程序端使用 UTF-8 编码。

于 2014-05-08T08:51:18.460 回答