Skip to content

Matching custom attribute starting by multiples zeros #1944

@Viinz

Description

@Viinz

I have a custom attribute for a product called DIN.
This DIN contains only numbers and can start with multiples zeros ie. 00812382 or 0007865235

I want to find them if I search for the DIN without zero :

  • 812382 should match 00812382
  • 7865235 should match 0007865235

I tried to create a customer filter and analyzer like this :

<index identifier="catalog_product" defaultSearchType="product">
    <type name="product" idFieldName="entity_id">
        <mapping>
            <!-- Static fields handled by the base indexer (not datasource) -->
            <field name="din" type="text">
                <isSearchable>1</isSearchable>
                <isUsedInSpellcheck>1</isUsedInSpellcheck>
                <defaultSearchAnalyzer>custom_din_analyzer</defaultSearchAnalyzer>
            </field>
        </mapping>
    </type>
</index>

elasticsuite_indices.xml

<filters>
    <filter name="ngram_filter_custom" type="edge_ngram" language="default">
        <min_gram>1</min_gram>
        <max_gram>20</max_gram>
    </filter>
</filters>

<analyzers>
    <analyzer name="custom_din_analyzer" tokenizer="standard" language="default">
        <filters>
            <filter ref="lowercase" />
            <filter ref="ngram_filter_custom"/>
        </filters>
    </analyzer>
</analyzers>

elasticsuite_analysis.xml

The spellcheck is enabled and changing the weight is still the same.

Do you have an idea about how I can get this ?

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions