处理solr数据导入器的嵌套实体中的空值

处理solr数据导入器的嵌套实体中的空值,solr,Solr,我正在使用Solr数据导入器导入一些类别数据。我不想在父查询中使用左连接,因为它太复杂了,我更喜欢在配置中使用嵌套对象查询来保持简单 我为一个类别的特征图像建立了3个一一对应的关系。但我的问题是,当mediaItemX_id字段中的值为空时,如何处理它?我尝试了下面的嵌套配置,但是当值为null时,它报告无效的sql,因为嵌套查询不打印null-它打印为空 <entity name="category" query="SELECT concat('CATEGORY_', c.id) as

我正在使用Solr数据导入器导入一些类别数据。我不想在父查询中使用左连接,因为它太复杂了,我更喜欢在配置中使用嵌套对象查询来保持简单

我为一个类别的
特征图像
建立了3个一一对应的关系。但我的问题是,当mediaItemX_id字段中的值为空时,如何处理它?我尝试了下面的嵌套配置,但是当值为null时,它报告无效的sql,因为嵌套查询不打印
null
-它打印为空

<entity name="category" query="SELECT concat('CATEGORY_', c.id) as docId, c.id, externalIdentifier, name, description, shortDescription, mediaItem1_id, mediaItem2_id, mediaItem3_id, created, lastUpdated, keywords, 'CATEGORY' as docType,
            name as autoSuggestField
         FROM categories c inner join base_content bc where c.id = bc.id">         
            <field column="id" name="categoryId" />
            <field column="externalIdentifier" name="externalIdentifier" />
            <field column="docType" name="docType" />
            <field column="name" name="name" />
            <field column="description" name="description" />       
            <field column="shortDescription" name="shortDescription" />       
            <field column="created" name="created" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" />
            <field column="lastUpdated" name="lastUpdated" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" /> 
            <field column="publishDate" name="publishDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" /> 
            <field column="archiveDate" name="archiveDate" dateTimeFormat="yyyy-MM-dd'T'HH:mm:ss" /> 
            <field column="autoSuggestField" name="suburbSuggest" /> 
            <field column="keywords" name="keywords" />
            <entity name="mediaItem1" query="SELECT uri, title, altText from media where ${category.mediaItem1_id} is not null and id = ${category.mediaItem1_id}">
                <field column="uri" name="featureImage1Url" />
                <field column="title" name="featureImage1Title" />
                <field column="altText" name="featureImage1AltText" />
            </entity>
            <entity name="mediaItem2" query="SELECT uri, title, altText from media where ${category.mediaItem2_id} is not null and id = ${category.mediaItem2_id}">
                <field column="uri" name="featureImage2Url" />
                <field column="title" name="featureImage2Title" />
                <field column="altText" name="featureImage2AltText" />
            </entity>
            <entity name="mediaItem1" query="SELECT uri, title, altText from media where ${category.mediaItem3_id} is not null and id = ${category.mediaItem3_id}">
                <field column="uri" name="featureImage3Url" />
                <field column="title" name="featureImage3Title" />
                <field column="altText" name="featureImage3AltText" />
            </entity>
</entity>

Solr支持${value:default}概念作为其他位置的替换,因此我至少会尝试:

${category.mediaItem1_id} IS NOT NULL AND id = ${category.mediaItem1_id:0}

如果当前值为false,我无法找到一种合适的方法来跳过整个实体。

Solr支持将${value:default}概念作为其他位置的替换,因此我至少会尝试:

${category.mediaItem1_id} IS NOT NULL AND id = ${category.mediaItem1_id:0}

如果当前值为false,我无法找到一种合适的方法来跳过整个实体。

谢谢,我尝试了它,但它不起作用,变量中的空格出现了相同的错误-选择uri、title、altText from media,其中${category.mediaItem1_id:-1}=idI在父查询中使用了ifnull,有效:SELECT concat('category_',c.id)as docId、c.id、externalIdentifier、name、description、shortDescription、IFNULL(mediatem1_id,-1)作为mediatem1_id、IFNULL(mediatem2_id,-1)作为mediatem2_id、IFNULL(mediatem3_id,-1)作为mediatem3_id、created、lastUpdated、关键字、“CATEGORY”作为docType、,将c.id=bc上的类别c内部联接基础内容bc命名为autoSuggestField。id@RichardG谢谢,如果你把答案贴出来,我会投你一票;-)谢谢,我试过了,但不起作用,变量中的空格出现了同样的错误-从媒体中选择uri、title、altText,其中${category.mediaItem1_id:-1}=idI在父查询中使用了ifnull,有效:选择concat('category_',c.id)作为docId、c.id、externalIdentifier、name、description、shortDescription、ifnull(mediaItem1_id,-1)作为mediaItem1_id,IFNULL(mediaItem2_id,-1)作为mediaItem2_id,IFNULL(mediaItem3_id,-1)作为mediaItem3_id,创建,最后更新,关键字,“CATEGORY”作为docType,名称作为autoSuggestField从类别c内部连接基内容bc到c.id=bc。id@RichardG谢谢,如果你把答案贴出来,我会投你一票;-)