我們試圖將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」字段。爲什麼? 我們錯過了任何一個步驟?我們是否必須配置其他的東西才能使映射工作?
@dove我想知道爲什麼你編輯刪除「提前致謝」的帖子... – spekdrum
@Spekdrum這個問題,它是對meta的答案http://meta.stackexchange.com/questions/2950/should-hi-thanks-taglines-and-salutations-be-removed-from-posts總結得很好。這並不是說你的感謝不受歡迎,希望你會學會喜歡精妙的禮儀,並學會欣賞和貢獻。 – dove
對不起,我沒有意識到我正在和一個機器人談話。 – spekdrum