[opencms-dev] Mapping OpenCMS structured content XML field to a SOLR field
Ramon Gavira
ramon.gavira at sagasoluciones.com
Mon Feb 11 19:32:02 CET 2013
Hi Arturo.
We have the same problema, did get it work??
-----Mensaje original-----
De: opencms-dev-bounces at opencms.org [mailto:opencms-dev-bounces at opencms.org]
En nombre de Arturo Martín Lladó
Enviado el: miércoles, 23 de enero de 2013 12:54
Para: opencms-dev at opencms.org
Asunto: [opencms-dev] Mapping OpenCMS structured content XML field to a SOLR
field
Hi,
We are trying to map an OpenCMS structured content XML field to a SOLR field
in order to perform a search using that field as a filter.
The XML field is described this way in the XSD file:
<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>
And these are the search settings for the element, defined in the same XSD
file:
<xsd:annotation>
<xsd:appinfo>
[...]
<searchsettings>
<searchsetting element="numeroExpediente" searchcontent="true">
<solrfield targetfield="numexp" />
</searchsetting>
</searchsettings>
[...]
</xsd:appinfo>
</xsd:annotation>
The target SOLR field "numexp" is defined this way in SOLR's schema.xml
file:
<fields>
<field name="numexp" type="string"
indexed="true" stored="true" />
[...]
</fields>
And this is the way we perform the query to SOLR on a JSP file:
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);
When we execute this code, we get listFiles.size() = 0, but when we change
the filter field to the predifined SOLR field "content", this
way:
if (!"".equals(text))
query += "&fq=content:" + text;
we get the expected result.
With the CmsSearchResource object we get using the "content" SOLR field as
filter, we are able to iterate over the fields of its inner
I_CmsSearchDocument, getting this list as result:
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
No presence of the "numexp" field on the list. Why? Are we missing any step?
Do we have to configure something else in order to make the mapping work?
Thank you in advance.
Regards,
Arturo.
_______________________________________________
This mail is sent to you from the opencms-dev mailing list To change your
list options, or to unsubscribe from the list, please visit
http://lists.opencms.org/cgi-bin/mailman/listinfo/opencms-dev
More information about the opencms-dev
mailing list