1

Solr と Broadleaf は初めてです。

私は、solr 検索を使用しているという点で、Broadleaf で作業しています。それは完全に問題なく、動作状態です。製品テーブルには現在、カテゴリ フィールドとカテゴリ別の広葉樹検索があります。要件に従って、製品テーブルを拡張し、会社 ID を使用して新しいテーブルを作成します。したがって、ExtendedProduct テーブルには、companyId と productId (製品テーブルを持つ fk) の 2 つのフィールドがあります。 companyId による製品リストも取得します。

schema.xml ファイルは以下のようになります

    <?xml version="1.0" encoding="UTF-8" ?>
<schema name="example" version="1.5">
    <fields>
        <field name="namespace" type="string" indexed="true" stored="false" />
        <field name="id" type="string" indexed="true" stored="true" />
        <field name="productId" type="long" indexed="true" stored="true" />
        <field name="category" type="long" indexed="true" stored="false" multiValued="true" />
        <field name="explicitCategory" type="long" indexed="true" stored="false" multiValued="true" />
        <field name="searchable" type="text_general" indexed="true" stored="false" />
        <dynamicField name="*_searchable" type="text_general" indexed="true" stored="false" />

        <dynamicField name="*_i" type="int" indexed="true" stored="false" />
        <dynamicField name="*_is" type="int" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_s" type="string" indexed="true" stored="false" />
        <dynamicField name="*_ss" type="string" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_l" type="long" indexed="true" stored="false" />
        <dynamicField name="*_ls" type="long" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_t" type="text_general" indexed="true" stored="false" />
        <dynamicField name="*_txt" type="text_general" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_b" type="boolean" indexed="true" stored="false" />
        <dynamicField name="*_bs" type="boolean" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_d" type="double" indexed="true" stored="false" />
        <dynamicField name="*_ds" type="double" indexed="true" stored="false" multiValued="true" />
        <dynamicField name="*_p" type="double" indexed="true" stored="false" />

        <dynamicField name="*_dt" type="date" indexed="true" stored="false" />
        <dynamicField name="*_dts" type="date" indexed="true" stored="false" multiValued="true" />

        <!-- some trie-coded dynamic fields for faster range queries -->
        <dynamicField name="*_ti" type="tint" indexed="true" stored="false" />
        <dynamicField name="*_tl" type="tlong" indexed="true" stored="false" />
        <dynamicField name="*_td" type="tdouble" indexed="true" stored="false" />
        <dynamicField name="*_tdt" type="tdate" indexed="true" stored="false" />
    </fields>

    <uniqueKey>id</uniqueKey>

    <types>
        <!-- The StrField type is not analyzed, but indexed/stored verbatim. -->
        <fieldType name="string" class="solr.StrField" sortMissingLast="true" />

        <!-- boolean type: "true" or "false" -->
        <fieldType name="boolean" class="solr.BoolField" sortMissingLast="true" />

        <!-- Default numeric field types. For faster range queries, consider the 
            tint/tlong/tdouble types. -->
        <fieldType name="int" class="solr.TrieIntField" precisionStep="0" positionIncrementGap="0" />
        <fieldType name="long" class="solr.TrieLongField" precisionStep="0" positionIncrementGap="0" />
        <fieldType name="double" class="solr.TrieDoubleField" precisionStep="0" positionIncrementGap="0" />

        <!-- Numeric field types that index each value at various levels of precision 
            to accelerate range queries when the number of values between the range endpoints 
            is large. See the javadoc for NumericRangeQuery for internal implementation 
            details. Smaller precisionStep values (specified in bits) will lead to more 
            tokens indexed per value, slightly larger index size, and faster range queries. 
            A precisionStep of 0 disables indexing at different precision levels. -->
        <fieldType name="tint" class="solr.TrieIntField" precisionStep="8" positionIncrementGap="0" />
        <fieldType name="tlong" class="solr.TrieLongField" precisionStep="8" positionIncrementGap="0" />
        <fieldType name="tdouble" class="solr.TrieDoubleField" precisionStep="8" positionIncrementGap="0" />

        <!-- The format for this date field is of the form 1995-12-31T23:59:59Z, 
            and is a more restricted form of the canonical representation of dateTime 
            http://www.w3.org/TR/xmlschema-2/#dateTime The trailing "Z" designates UTC 
            time and is mandatory. Optional fractional seconds are allowed: 1995-12-31T23:59:59.999Z 
            All other components are mandatory. Expressions can also be used to denote 
            calculations that should be performed relative to "NOW" to determine the 
            value, ie... NOW/HOUR ... Round to the start of the current hour NOW-1DAY 
            ... Exactly 1 day prior to now NOW/DAY+6MONTHS+3DAYS ... 6 months and 3 days 
            in the future from the start of the current day Consult the DateField javadocs 
            for more information. Note: For faster range queries, consider the tdate 
            type -->
        <fieldType name="date" class="solr.TrieDateField" precisionStep="0" positionIncrementGap="0" />

        <!-- A Trie based date field for faster date range queries and date faceting. -->
        <fieldType name="tdate" class="solr.TrieDateField" precisionStep="6" positionIncrementGap="0" />

        <!-- A general text field that has reasonable, generic cross-language defaults: 
            it tokenizes with StandardTokenizer and down cases. -->
        <fieldType name="text_general" class="solr.TextField" positionIncrementGap="100">
            <analyzer type="index">
                <tokenizer class="solr.StandardTokenizerFactory" />
                <filter class="solr.LowerCaseFilterFactory" />
            </analyzer>
            <analyzer type="query">
                <tokenizer class="solr.StandardTokenizerFactory" />
                <filter class="solr.LowerCaseFilterFactory" />
            </analyzer>
        </fieldType>

    </types>
</schema>

そしてsolrConfig.xmlファイルは次のようになります

<?xml version="1.0" encoding="UTF-8" ?>
<config>
    <abortOnConfigurationError>${solr.abortOnConfigurationError:true} </abortOnConfigurationError>
    <luceneMatchVersion>LUCENE_40</luceneMatchVersion>
    <directoryFactory name="DirectoryFactory" class="${solr.directoryFactory:solr.StandardDirectoryFactory}" />
    <updateHandler class="solr.DirectUpdateHandler2" />

    <query>
        <maxBooleanClauses>1024</maxBooleanClauses>

        <filterCache class="solr.FastLRUCache" size="512" initialSize="512" autowarmCount="0" />
        <queryResultCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0" />
        <documentCache class="solr.LRUCache" size="512" initialSize="512" autowarmCount="0" />

        <enableLazyFieldLoading>true</enableLazyFieldLoading>

        <queryResultWindowSize>20</queryResultWindowSize>
        <queryResultMaxDocsCached>200</queryResultMaxDocsCached>

        <listener event="newSearcher" class="solr.QuerySenderListener" />
        <listener event="firstSearcher" class="solr.QuerySenderListener">
            <arr name="queries">
                <lst>
                    <str name="q">static firstSearcher warming in solrconfig.xml</str>
                </lst>
            </arr>
        </listener>

        <useColdSearcher>false</useColdSearcher>
        <maxWarmingSearchers>2</maxWarmingSearchers>
    </query>

    <requestDispatcher>
        <requestParsers enableRemoteStreaming="true" multipartUploadLimitInKB="2048000" />
        <httpCaching never304="true" />
    </requestDispatcher>

    <requestHandler name="/select" class="solr.SearchHandler">
        <lst name="defaults">
            <str name="echoParams">explicit</str>
            <int name="rows">4</int>
            <str name="df">name_t</str>
        </lst>
    </requestHandler>

    <requestHandler name="/update" class="solr.UpdateRequestHandler" />
    <requestHandler name="/update/csv" class="solr.CSVRequestHandler" startup="lazy" />
    <requestHandler name="/update/json" class="solr.JsonUpdateRequestHandler" startup="lazy" />

    <queryResponseWriter name="json" class="solr.JSONResponseWriter">
        <str name="content-type">text/plain; charset=UTF-8</str>
    </queryResponseWriter>

</config>

現在、広葉樹では、カテゴリ:2023 のクエリを配置しています。以下は、q=category%3A2003&fl=id&rows=15&fq=namespace%3Ad&start=0 のような SolrQuery.toString です。

テーブル名がこれにどのように/どこで構成されているかはまだわかりません。

companyId で製品を検索したいのですが、これを行うにはどの変更を行う必要がありますか?

前もってありがとう、アンキット

4

1 に答える 1

3

これに関する主なドキュメント リンクはhttp://docs.broadleafcommerce.org/current/Catalog-and-Search.htmlにあります。

これの顕著な点を以下にコピーします。

動的フィールド

これらのフィールドは、blc_field および blc_field_search_types のデータベース エントリを介してユーザーによって指定されます。Field の正確な内容について説明する前に、Solr の動的フィールドとは何かを説明する必要があります。schema.xml を開くと、さまざまなフィールドのリストが表示されます。短い抜粋は次のとおりです。

ここでは、いくつかの動的フィールドを定義しています。たとえば、manufactuer_s という名前のフィールドを作成する場合、Solr によって Solr.StrField としてインデックスが作成されます。

もう 1 つの重要な違いは、FieldImpl の 2 つのプロパティである searchableFieldTypes と facetFieldType です。検索可能なフィールド タイプは Solr インデックスに組み込まれ、複数のタイプを持つことができます。たとえば、フィールドを文字列フィールドとテキスト フィールドの両方としてインデックス付けすることができます (テキスト フィールドでは部分一致が許可されます)。ただし、文字列フィールドでのみファセットする必要があります。Broadleaf Field の実装により、この自由が得られます。また、ファセット フィールドは、並べ替えに使用する Solr インデックスも制御することに注意してください。

簡単な例として、次のフィールドが定義されている場合に何が起こるかを見てみましょう。

製造元、facetFieldType: "s"、searchableFieldTypes: { "s"、"t" } defaultSku.retailPrice、facetFieldType: "d" defaultSku.name、facetField: "s"、searchableFieldTypes: { "s"、"t" } およびサンプル製品を索引付けします。JSON での適切な Solr 表現は次のようになります。

{ id : 100、カテゴリ : [2000、2002]、manufacturer_s : "スパイス エクスチェンジ"、
manufacturer_t : "スパイス エクスチェンジ"、
defaultSku.retailPrice_d : 6.99、defaultSku.name_s : "死者の日スコッチ ボンネット ホット ソース"、defaultSku. name_t : "Day of the Dead スコッチ ボンネット ホット ソース", searchable : "Spice Exchange Day of the Dead スコッチ ボンネット ホット ソース" }

検索可能なフィールドとは何なのか疑問に思われるかもしれません。フィールドを検索可能として指定すると、フィールドの値が検索可能な solr インデックス フィールドにコピーされます。後でクエリを実行すると、このフィールドに対してクエリが実行されます。

すぐにこれに戻り、並べ替え、検索、およびファセットがこの製品に対してどのように機能するかを確認します.

したがって、基本的には、propertyName フィールドの「companyId」を持つ BLC_FIELD (FieldImpl Java クラス) へのエントリを定義します。プロジェクトの load_catalog_data.sql から、「manufacturer」フィールドをインポートして検索する方法は次のとおりです。

INSERT INTO BLC_FIELD (FIELD_ID, ENTITY_TYPE, PROPERTY_NAME, ABBREVIATION, SEARCHABLE, FACET_FIELD_TYPE) VALUES (1, 'PRODUCT', 'manufacturer', 'mfg', 1, 's');
于 2013-06-07T15:53:52.620 に答える