• Solr报错org.apache.solr.common.SolrException: undefined field text


    有2个原因会导致报这个错,一般2个原因都要处理才能解决。

    原因一:

    collection的solrconfig.xml的firstSearcher事件的queries属性没配置,用了默认值

    解决方法:

    修改solrconfig.xml文件

    vim /solr/configsets/你的collection名/conf/solrconfig.xml

    找到这段:

    <listener event="firstSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
        <lst>
          <str name="q">static firstSearcher warming in solrconfig.xml</str>
        </lst>
      </arr>
    </listener>

    修改<str name="q"></str>的值为*:*,修改后如下:

    <listener event="firstSearcher" class="solr.QuerySenderListener">
      <arr name="queries">
        <lst>
          <str name="q">*:*</str>
        </lst>
      </arr>
    </listener>

    如果是用ZooKeeper的,需要重新上传配置到ZooKeeper:

    /solr/server/scripts/cloud-scripts/zkcli.sh -cmd upconfig -zkhost 地址1:2181,地址2:2181,地址3:2181 -confdir /solr/configsets/你的collection名/conf -confname 你的配置名

    重新新建collection即可。

    原因二:

    collection的solrconfig.xml的多个属性用了text字段作为默认检索字段

    如果schema.xml(新版是managed-schema)文件没有定义该字段,则会报错

    可以通过在solrconfig.xml文件检索<str name="df">text</str>找到具体的配置项

    针对这个原因,有2种解决方法——

    解决方法1:

    修改solrconfig.xml,把使用text字段的属性改成schema.xml(新版是managed-schema)有配置的字段名,例如id或title

    也就是vim solrconfig.xml,把<str name="df">text</str>替换成<str name="df">id</str>

    解决方法2:

    在schema.xml(新版是managed-schema)文件中添加text字段

    vim schema.xml  #新版是vim managed-schema

    添加一行:

    <field name="text" type="text_general" indexed="true" stored="true" />

    如果没配置text_general类型(fieldType),也需要先加上:

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

    如果是用ZooKeeper的,需要重新上传配置到ZooKeeper:

    /solr/server/scripts/cloud-scripts/zkcli.sh -cmd upconfig -zkhost 地址1:2181,地址2:2181,地址3:2181 -confdir /solr/configsets/你的collection名/conf -confname 你的配置名

    重新新建collection即可。

  • 相关阅读:
    [leetcode] Rotate Image
    [leetcode] Jump Game II
    [leetcode] Permutations II
    [leetcode] Permutations
    [leetcode] Wildcard Matching
    [leetcode] Multiply Strings
    [leetcode] Trapping Rain Water
    [leetcode] First Missing Positive
    [leetcode] Combination Sum II
    [leetcode] Combination Sum
  • 原文地址:https://www.cnblogs.com/live41/p/15715340.html
Copyright © 2020-2023  润新知