Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/solr/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Indexing Solr模式正则表达式转换器_Indexing_Solr - Fatal编程技术网

Indexing Solr模式正则表达式转换器

Indexing Solr模式正则表达式转换器,indexing,solr,Indexing,Solr,我试图对定义到solr模式中的字段执行内部转换 我已将这两个字段添加到我的schema.xml中: <field name="source_file" type="string" indexed="true" stored="true" docValues="true"/> <copyField source="source_file_extraction" dest="text"/> : : 字段source_文件包含我的索引文档的基本名称(例如:1234_hel

我试图对定义到solr模式中的字段执行内部转换

我已将这两个字段添加到我的schema.xml中:

<field name="source_file" type="string" indexed="true" stored="true" docValues="true"/>
<copyField source="source_file_extraction" dest="text"/> :

:
字段source_文件包含我的索引文档的基本名称(例如:1234_helloworld.pdf)。 我想使用正则表达式从此基名称提取一些数据(例如:提取所有数字(\d*)=>1234)},并将此提取保存到字段源文件中

为此,我发现使用正则表达式变压器是可能的。 我将文件solr-data-config.xml配置为:

<dataConfig>
  <document>
    <entity name="source_file_extraction" transformer="RegexTransformer" query="select coll from source_file_extraction">
        <field column="coll" regex=".*?-(\d\d)-.*" sourceColName="source_file"/>
    </entity>
  </document>
</dataConfig>

我将requestHandler添加到文件solrconfig.xml中:

<requestHandler name="/dataimport" class="solr.DataImportHandler">
  <lst name="defaults">
    <str name="config">solr-data-config.xml</str>
  </lst>
</requestHandler>

solr-data-config.xml
但它不起作用

如何通过正则表达式将模式中定义的字段简单转换为同一模式的另一个字段


提前感谢您的帮助。

使用
solr.PatternReplaceFilterFactory
过滤器工厂进行字段“源文件提取”

如下所示,为字段
源文件\u提取更新模式文件

<field name="source_file_extraction" type="NameExtractor" indexed="true" stored="true"/>

<fieldType name="NameExtractor" class="solr.TextField" positionIncrementGap="100">
   <analyzer>
      <tokenizer class="solr.KeywordTokenizerFactory"/>
      <filter class="solr.PatternReplaceFilterFactory" pattern="([^0-9])" replacement="" replace="all"/>
   </analyzer>
</fieldType>

将复制字段从源文件添加到源文件

<copyField source="source_file" dest="source_file_extraction"/>

当令牌被复制到字段
源文件\u提取时
使用过滤器,仅保留该值中的数字字符并存储

它不修改
源文件
字段值

不要忘记在模式修改后重新启动solr

希望这有帮助,
vinod

在索引字段中,复制的内容与源内容完全相同。过滤器没有被反射。但是,如果对文本执行相同操作,我可以在“分析”选项卡中看到预期的更改。你知道如何使这些变化也反映solr核心领域的变化吗?短暂性脑缺血发作