1

我对 Solr 的拼写检查建议有一个奇怪的问题。

我搜索这样的术语(例如产品编号):08p17a6

使用这个术语,我在我的索引中找到文档。

我已启用拼写检查 = true。所以除了文档之外,solr 还在 xml 响应中给了我一个拼写检查建议:

<lst name="spellcheck">
    <lst name="suggestions">
        <lst name="p17a6">
            <int name="numFound">1</int>
            <int name="startOffset">2</int>
            <int name="endOffset">7</int>
            <arr name="suggestion">
                <str>08p17a6</str>
            </arr>
        </lst>
    </lst>
</lst>

Solr 采用我的搜索词的第一个数字,并根据“p17a6”给我一个建议。我不明白他为什么会为了他的建议而删掉前两个数字。

如果我启用 spellcheck.collat​​e,事情会变得更奇怪:

<lst name="spellcheck">
    <lst name="suggestions">
        <lst name="p17a6">
            <int name="numFound">1</int>
            <int name="startOffset">2</int>
            <int name="endOffset">7</int>
            <arr name="suggestion">
                <str>08p17a6</str>
            </arr>
        </lst>
        <str name="collation">0808p17a6</str>
    </lst>
</lst>

我需要使用 spellcheck.collat​​e 来获得关于多个搜索词的建议。但如您所见,xml 响应建议我使用“0808p17a6”。

有谁知道这是怎么回事?

编辑:

这是我关于拼写检查的架构配置:

<field name="spell" type="textSpell" indexed="true" stored="false" multiValued="true" />
<copyField source="title"    dest="spell" />
<copyField source="subTitle" dest="spell" />
<copyField source="content"  dest="spell" />

复制字段的源字段配置如下:

<field name="title"       type="text"   indexed="true"  stored="true" termVectors="true" omitNorms="true" />
<field name="subTitle"    type="text"   indexed="true"  stored="true" termVectors="true" omitNorms="true" />
<field name="content"     type="text"   indexed="true"  stored="true" termVectors="true" />

这是分析器的配置:

        <filter class="solr.WordDelimiterFilterFactory"
            generateWordParts="1"
            generateNumberParts="1"
            catenateWords="1"
            catenateNumbers="1"
            catenateAll="0"
            splitOnCaseChange="1"
            preserveOriginal="1"
        />
        <!-- best practice (currently) for synonyms is to add them by
            expansions during index time
        -->
        <filter class="solr.SynonymFilterFactory" synonyms="german/synonyms.txt" ignoreCase="true" expand="true"/>
        <!-- Case insensitive stop word removal.
            add enablePositionIncrements=true in both the index and query
            analyzers to leave a 'gap' for more accurate phrase queries.
        -->
        <filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true" enablePositionIncrements="true"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="German2" protected="german/protwords.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.WhitespaceTokenizerFactory"/>

        <filter class="solr.WordDelimiterFilterFactory"
            generateWordParts="1"
            generateNumberParts="1"
            catenateWords="0"
            catenateNumbers="0"
            catenateAll="0"
            splitOnCaseChange="1"
            preserveOriginal="1"
        />
        <filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true" enablePositionIncrements="true"/>
        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SnowballPorterFilterFactory" language="German2" protected="german/protwords.txt"/>
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
</fieldType>

<!-- Setup simple analysis for spell checking -->
<fieldType name="textSpell" class="solr.TextField" positionIncrementGap="100" omitNorms="true">
    <analyzer type="index">
        <tokenizer class="solr.StandardTokenizerFactory"/>

        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.SynonymFilterFactory" synonyms="german/synonyms.txt" ignoreCase="true" expand="true"/>
        <filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true"/>
        <filter class="solr.StandardFilterFactory" />
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.StandardTokenizerFactory" />

        <filter class="solr.LowerCaseFilterFactory"/>
        <filter class="solr.StopFilterFactory" words="german/stopwords.txt" ignoreCase="true"/>
        <filter class="solr.StandardFilterFactory" />
        <filter class="solr.RemoveDuplicatesTokenFilterFactory"/>
    </analyzer>
</fieldType>
4

0 回答 0