3

そのフィールドをフィルターとして使用して検索を実行するために、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>

これは、JSP ファイルで SOLR にクエリを実行する方法です。

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 になりますが、フィルター フィールドを事前に定義された SOLR フィールド「content」に変更すると、次のようになります。

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」フィールドが存在しません。なんで?何かステップがありませんか?マッピングを機能させるために何か他の設定をする必要がありますか?

4

2 に答える 2