我们试图将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