2013-01-23 59 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丁資源,不要忘記重新索引你的太陽能指數!

相關問題