2013-01-23 60 views
3

我们试图将OpenCMS结构化内容XML字段映射到SOLR字段,以便使用该字段作为过滤器执行搜索。将OpenCMS结构化内容XML字段映射到SOLR字段

的XML字段中描述这种方式在XSD文件:

<xsd:complexType name="OpenCmsContrato"> 
    <xsd:sequence> 
    [...] 
     <xsd:element name="numeroExpediente" type="OpenCmsString" minOccurs="1" maxOccurs="1" /> 
    [...] 
    </xsd:sequence> 
    <xsd:attribute name="language" type="OpenCmsLocale" use="required"/> 
</xsd:complexType> 

这些是该元素的搜索设置,在相同的XSD文件中定义:

<xsd:annotation> 
    <xsd:appinfo> 
    [...] 
     <searchsettings> 
      <searchsetting element="numeroExpediente" searchcontent="true"> 
       <solrfield targetfield="numexp" /> 
      </searchsetting> 
     </searchsettings> 
    [...] 
    </xsd:appinfo> 
</xsd:annotation> 

目标SOLR字段“numexp”在SOLR的schema.xml文件中以这种方式定义:

<fields> 
    <field name="numexp"     type="string"  indexed="true" stored="true" /> 
    [...] 
</fields> 

这就是我们执行的方式米查询SOLR在JSP文件:

CmsSearchManager manager = OpenCms.getSearchManager(); 
CmsSolrIndex index = manager.getIndexSolr("Solr Online"); 

String query = "fq=type:contrato"; 

if (!"".equals(text)) 
    query += "&fq=numexp:" + text; 

CmsSolrResultList listFiles = index.search(cmso, query); 

当我们执行这个代码,我们得到listFiles.size()= 0,但是当我们在过滤器字段更改为predifined SOLR领域的“内容”,这方式:

if (!"".equals(text)) 
    query += "&fq=content:" + text; 

我们得到了预期的结果。

随着我们开始使用“内容” SOLR字段作为过滤器CmsSearchResource对象,我们可以遍历其内部I_CmsSearchDocument领域,获得这个列表作为结果:

id 
contentblob 
path 
type 
suffix 
created 
lastmodified 
contentdate 
relased 
expired 
res_locales 
con_locales 
template_prop 
default-file_prop 
notification-interval_prop 
NavPos_prop 
enable-notification_prop 
locale_prop 
NavText_prop 
Title_prop 
category 
ca_excerpt 
timestamp 
score 
link 

的不存在列表中的“numexp”字段。为什么? 我们错过了任何一个步骤?我们是否必须配置其他的东西才能使映射工作?

+0

@dove我想知道为什么你编辑删除“提前致谢”的帖子... – spekdrum

+0

@Spekdrum这个问题,它是对meta的答案http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts总结得很好。这并不是说你的感谢不受欢迎,希望你会学会喜欢精妙的礼仪,并学会欣赏和贡献。 – dove

+0

对不起,我没有意识到我正在和一个机器人谈话。 – spekdrum

回答

2

几个月前我有同样的问题。 我觉得这是你的问题

<searchsetting element="numeroExpediente" searchcontent="true"> 
    <solrfield targetfield="numexp" /> 
</searchsetting> 

你必须改变这种

<searchsetting element="numeroExpediente" searchcontent="true"> 
    <solrfield targetfield="numexp" sourcefield="*_s" /> 
</searchsetting> 

您必须设置solrfield的类型,看看到型动物类型,在SOLR的架构。 xml,我为博客元素中的某个类别做了这个。在v9.0.1中工作

0

我们遇到了同样的问题。事情是SOLR不会索引嵌套的内容本身,你必须说是否该字段应该索引或不。

例如,让我们说我们有一个事件XSD,包含关于事件与公司信息

<xsd:complexType name="OpenCmsEvent"> 
    <xsd:sequence> 
     <xsd:element name="EventInformation" type="OpenCmsEventInformation" minOccurs="1" maxOccurs="1" /> 
     <xsd:element name="EventHost" type="OpenCmsEventHost" minOccurs="0" maxOccurs="1" /> 
    </xsd:sequence> 
    <xsd:attribute name="language" type="OpenCmsLocale" use="required" /> 
</xsd:complexType> 

我们想知道从Eventhost

<xsd:complexType name="OpenCmsEventHost"> 
    <xsd:sequence> 
     <xsd:element name="company" type="OpenCmsVfsFile" minOccurs="1" maxOccurs="unbounded" /> 
    </xsd:sequence> 
    <xsd:attribute name="language" type="OpenCmsLocale" use="optional" /> 
</xsd:complexType> 

的链接,该公司以下映射会给我们提供我们想要的信息

<searchsettings> 
    <searchsetting element="EventHost/company" searchcontent="true"> 
      <solrfield targetfield="companyurl"/> 
    </searchsetting> 
</searchsettings> 

在exis丁资源,不要忘记重新索引你的太阳能指数!

相关问题