Solr:PatternReplaceFilterFactory 是否能够替换 copyField 的字段值然后对其进行索引? [英] Solr: Does the PatternReplaceFilterFactory able to replace the field value for copyField and then index it?

查看:52
本文介绍了Solr:PatternReplaceFilterFactory 是否能够替换 copyField 的字段值然后对其进行索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经索引了 solr 包附带的 solr.xml 和 monitor.xml 中的数据,并在 schema.xml 文件中添加了以下配置

I have indexed the data from solr.xml and monitor.xml that came with the solr package, and I added the below configuration in the schema.xml file

<field name="my_field" type="my_field_type" indexed="true" stored="true" required="false"/>
<copyField source="name" dest="my_field" />
<fieldType name="my_field_type" class="solr.TextField">
      <analyzer type="index">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.PatternReplaceFilterFactory" pattern=".*" replacement="NameChanged" replace="all" />
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
      <analyzer type="query">
        <tokenizer class="solr.KeywordTokenizerFactory"/>
        <filter class="solr.LowerCaseFilterFactory"/>
      </analyzer>
</fieldType>

它将(name) 字段复制到fieldType (my_field_type) 的(my_field).在 (my_field_type) 中,我使用 PatternReplaceFilterFactory 尝试用字符串NameChanged"替换所有内容.结果是它确实将(name)字段及其值复制到(my_field),但值仍然保持不变.例如下面返回的结果带有(name)和(my_field)字段,这两个字段的值字段相同,它没有将字段 (my_field) 的值更改为NameChanged"

It copies the (name) field to (my_field) of the fieldType (my_field_type). In the (my_field_type), I used PatternReplaceFilterFactory trying to replace everything with the string "NameChanged". The result is that it did copy the (name) field and its value to (my_field), but the value still stays the same.For example the below returned results with the (name) and (my_field) fields, the values of those two fields are the same, it didn't change the value to "NameChanged" for the field (my_field)

<?xml version="1.0" encoding="UTF-8"?>
<response>

<lst name="responseHeader">
  <int name="status">0</int>
  <int name="QTime">2</int>
  <lst name="params">
    <str name="fl">id,name,my_field,</str>
    <str name="indent">true</str>
    <str name="q">*:*</str>
    <str name="_">1380593840070</str>
    <str name="wt">xml</str>
  </lst>
</lst>
<result name="response" numFound="2" start="0">
  <doc>
    <str name="id">SOLR1000</str>
    <str name="name">Solr, the Enterprise Search Server</str>
    <str name="my_field">Solr, the Enterprise Search Server</str></doc>
  <doc>
    <str name="id">3007WFP</str>
    <str name="name">Dell Widescreen UltraSharp 3007WFP</str>
    <str name="my_field">Dell Widescreen UltraSharp 3007WFP</str></doc>
</result>
</response>

那么,PatternReplaceFilterFactory 是否能够替换 copyField 的字段值,然后对其进行索引?如果是,我在上面的配置中做错了什么?

So, does the PatternReplaceFilterFactory able to replace the field value for copyField and then index it? If yes, what did I do wrong in the above configuration?

推荐答案

分析器链用于字段的标记化(可搜索)表示.您显示的结果是针对原始存储表示的.这就是为什么您不会看到任何变化的原因.

The analyzer chain is for tokenized (searchable) representation of the field. The result you are showing is for original stored representation. That's why you will not see any changes that way.

相反,在字段分析器屏幕或模式描述字段(带有选中标记以加载令牌的字段)中检查管理界面中的标记化表示.或者,为了快速测试,使用 my_field 作为方面,因为方面使用实际标记.

Instead, check the tokenized representation in Admin interface either in field analyzer screen or in schema description field (one with checkmark to load tokens). Or, for a quick test, use my_field as a facet, as facet uses the actual tokens.

如果您尝试更改实际存储的表示以及索引的表示,最好使用使用 CloneFieldUpdateProcessorFactoryRegexReplaceProcessorFactory.这在 solrconfig.xml 中定义并在文档被存储/索引之前应用于文档.

If you are trying to change the actual stored representation, as well as indexed one, you are better off with UpdateRequestProcessor chain using CloneFieldUpdateProcessorFactory and RegexReplaceProcessorFactory. That's defined in solrconfig.xml and applies on the document before it is stored/indexed at all.

这篇关于Solr:PatternReplaceFilterFactory 是否能够替换 copyField 的字段值然后对其进行索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆