Exception writing document id to the index; possib

2019-02-18 01:36发布

问题:

I am getting the above error while indexing the documents.

<field name="a_suggest" type="my_suggest_field" indexed="true" stored="false"/>
<field name="b_suggest" type="my_suggest_field" indexed="true" stored="false" />
<field name="c_suggest" type="my_suggest_field" indexed="true" stored="false"/>

  <fieldType name="my_suggest_field" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory" />
        <filter class="solr.EdgeNGramFilterFactory" maxGramSize="10" minGramSize="2"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
  </fieldType>

And I am getting error when calling..

server.add(documents);

First of all, what is the meaning of Possible analysis error? Is it related to my_suggest_field index analyzer. Is it due to the order of the tokens, filters in the index analyzer?

Thanks.

回答1:

I am going to piggy back off this question because it is one of the first ones that comes up when looking for this issue and there are no general answers.

I was getting the same problem when trying to use the update API to add a document using a json. Come to find out one of my fields in solr was not formatted correctly as I was trying to save an XML string into a string field. I had to change the field to text_general.

The error is basically saying that what you are entering might not fit with your schema. Check each of your fields by adding them to the update 1 at a time. Then change as necessary.



回答2:

I need to create a separate field types for EdgeNGramFilterFactory and normal suggest.

  <field name="my_suggest" type="my_suggest_field" indexed="true" stored="false"/>
  <field name="my_suggest_ngram" type="my_suggest_ngram_field" indexed="true" stored="false"/>

  <fieldType name="my_suggest_field" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <filter class="solr.LowerCaseFilterFactory" />
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory" />
        <filter class="solr.LowerCaseFilterFactory" />
    </analyzer>
  </fieldType>

  <fieldType name="my_suggest_ngram_field" class="solr.TextField" positionIncrementGap="100">
        <analyzer type="index">
            <filter class="solr.LowerCaseFilterFactory" />
            <tokenizer class="solr.WhitespaceTokenizerFactory"/>
            <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="10"/>
        </analyzer>
        <analyzer type="query">
            <tokenizer class="solr.StandardTokenizerFactory" />
            <filter class="solr.LowerCaseFilterFactory" />
        </analyzer>
  </fieldType>


标签: java solr solrj