Solr5 中的 EdgeNGramFilterFactory 更改

EdgeNGramFilterFactory change in solr5

简短版本:

有人知道 Solr5 的 EdgeNGramFilterFactory 是否发生了什么事吗?它曾经在 solr 4 上运行良好,但我刚刚升级到 solr5,并且具有使用此过滤器的此字段的核心拒绝加载 ...

长话短说:

此配置用于 solr4.10 (schema.xml):

<field name="NAME" type="string" indexed="true" stored="true" required="true" multiValued="false"/>
<field name="PP" type="text_prefix" indexed="true" stored="false" required="false" multiValued="false"/>

<copyField source="NAME" dest="PP">

<fieldType name="text_prefix" class="solr.TextField" positionIncrementGap="100">
    <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.EdgeNGramFilterFactory" minGramSize="2" maxGramSize="15" side="front"/>
    </analyzer>
    <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
    </analyzer>
</fieldType>

并且 documentation 说我做对了(没有明确说明是用于 solr4 还是 solr5)。

但是,当我尝试使用此配置添加集合时,失败并显示以下消息:

<lst name="failure">
<str>
   org.apache.solr.client.solrj.impl.HttpSolrClient$RemoteSolrException:Error from server at http://localhost:8983/solr: Error CREATEing SolrCore 'test_collection': Unable to create core [test_collection] Caused by: Unknown parameters: {side=front}</str>
</lst>

我删除了 side=front "unknown" 参数,从头开始并且它有效 - 意味着不再有错误。

因此,虽然它过去在没有任何额外更改的情况下适用于 solr4,但它不再适用于 solr5。有什么改变吗?我错过了关于这个过滤器的任何文档吗?我需要加载任何额外的库才能完成这项工作吗?

最后,如果上面的意思是这样的 (bug/feature/whatever) - 是否有任何变通方法来获得此 "side-substring" 索引功能而无需在以下情况下生成值我正在向 solr 添加文档?

Update:使用 "hacked" 架构(即没有 side=front),我索引了文档并将 PP 字段更改为存储。当我搜索时,它似乎索引了整个值。例如,对于 NAME:ELEPHANT,我发现 PP:ELEPHANT ...

该属性 side has been removed in the context of LUCENE-3907 在版本 4.4 中。这个过滤器现在总是表现得像你给了 side="front"。所以你可以删除那个属性并且很好,因为你正在使用它 "front-way".

正如您在链接的 Lucene Issue 的对话中所读到的那样

If you need reverse n-grams, you could always add a filter to do that afterwards. There is no need to have this as separate logic in this filter. We should split logic and keep filters as simple as possible.

这就是已经完成的。 side 属性已从过滤器中删除。

这是在 Lucene 中完成的,而不是直接在 Solr 中完成的。因为 Lucene 是一个 Java-API 它已经被提到 in the Java Doc of the filter

As of Lucene 4.4, this filter does not support EdgeNGramTokenFilter.Side.BACK (you can use ReverseStringFilter up-front and afterward to get the same behavior), handles supplementary characters correctly and does not update offsets anymore.

这可能是您在 Solr 文档中找不到关于它的一个词的原因。但是这个改动也被提到了in Lucene's Change Log.