SOLR:使用splitBy填充多值字段的不一致 [英] SOLR: Inconsistencies using splitBy to populate a multi valued field

查看:322
本文介绍了SOLR:使用splitBy填充多值字段的不一致的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在使用splitBy功能从管道定界数据源填充多值字段时遇到麻烦.我的实现似乎只对一个领域起作用,而对另一领域则不起作用.下面是我的实现示例.

I'm having trouble using the splitBy functionality to populate a multi valued field from a pipe delimited datasource. My implementation seems to partially work for one of the field and does not the work for the the other field. An example of my implementation below.

我有一个包含以下数据的数据库视图:

I have a db view with following data:

1 PA21 | MD29香港巨龙|去皮的苹果

1 PA21|MD29 The Hong Kong Dragon|The Peeled Apple

我的配置:

<dataConfig>
    <dataSource name="jdbc" driver="oracle.jdbc.driver.OracleDriver" url="jdbc:oracle:thin:@myserver:1521:XE" user="MyUser" password="MyPassword"/>
    <document>
        <entity name="mentity" query="select * from MySampleView" transformer="RegexTransformer" >
            <field sourceColName="relist" column="relist" splitBy="\|"  />               
            <field sourceColName="dbaName" column="dbaName" splitBy="\|"  />
            <field column="recordId" name="recordId" />
        </entity>  
    </document>
</dataConfig>

我的schema.xml代码段:

<fields>    
    <field name="relist"      type="string"    indexed="true"  stored="true"  multiValued="true" /> 
    <field name="dbaName"      type="string"    indexed="true"  stored="true"  multiValued="true" />
    <field name="recordId"        type="string"    indexed="true"  stored="true"  multiValued="false" />
</fields>

<uniqueKey>recordId</uniqueKey>

我的期望是,当数据被拆分和存储时,文档将看起来像这样:

My expectation is that when the data is split and stored, that the document would look something like this:

"docs": [ 
  { 
    "relist": [ 
      "PA21", 
      "MD29" 
    ], 
    "recordId": "1", 
    "dbaName": [ 
      "The Hong Kong Dragon", 
      "The Peeled Apple" 
    ] 
  } 
] 

但是,这就是我得到的:

However, this is what I get:

"docs": [ 
  { 
    "relist": [ 
      "PA21", 
      "MD29", 
      "PA21|MD29" 
    ], 
    "recordId": "1", 
    "dbaName": [ 
      "The Hong Kong Dragon|The Peeled Apple" 
    ] 
  } 
] 

我的问题:

  1. relist正在拆分,但列表中还包含原始定界值
  2. dbaName未被拆分

任何帮助将不胜感激.

Any help would be appreciated.

谢谢

推荐答案

我最近遇到了同样的问题,并发现如果您的字段名称具有dbaName之类的mixCase,那么在未指定sourceColName的情况下splitby无效.您可以通过在SQL查询中使用临时名称来解决此问题,如下所示:

I recently ran into this same issue, and discovered that if your field name has mixedCase, like dbaName, then splitby does not work without specifying the sourceColName. You can fix this by using a temporary name in your SQL query, like so:

    <entity name="mentity" query="select dbaName as dba_name from MySampleView" transformer="RegexTransformer" >
        <field sourceColName="dba_name" column="dbaName" splitBy="\|"  />
    </entity>  

另一个选择是调用数据库列dba_name和字段名dba_name.然后splitBy可以很好地工作,而无需指定sourceColName.

The other option would be to call your database column dba_name and your field name dba_name. Then splitBy works just fine, without specifying sourceColName.

我发现这很令人困惑,所以这里还有一个例子,只是让每个人都清楚明白

I found this quite confusing, so here is one more example, just to make it crystal clear to every one

将不会起作用:

select 'foo|bar' as genRes
<field column="genres" sourceColName="genRes" splitBy="\|" />

起作用

select 'foo|bar' as genres
<field column="genres" sourceColName="genres" splitBy="\|" />

这篇关于SOLR:使用splitBy填充多值字段的不一致的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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