Elasticsuite: How to write a custom analyzer

Created on 21 Aug 2018  路  4Comments  路  Source: Smile-SA/elasticsuite

I need to implement custom char_filter (mapping), How do I this?

I think It should be simple as editing elasticsuite_analysis.xml,

<char_filters>
        <char_filter name="html_strip" type="html_strip" language="default"/>
        <char_filter name="custom_mapper" type="mappings" language="default">
            <mappings>["x => y", "a => b"]</<mappings>
        </char_filter>
</char_filters>

Any help appreciate :)

question

Most helpful comment

Ok so I tried with the following syntax :

    <char_filters>
        <char_filter name="html_strip" type="html_strip" language="default"/>
        <char_filter name="custom_mapper" type="mapping" language="default">
            <mappings>["x => y", "a => b"]</mappings>
        </char_filter>
    </char_filters>

Please note the "type=mapping" without the S.

And ran a reindex. Mapping is shown in Elasticsearch like this :

"char_filter": {
            "custom_mapper": {
              "type": "mapping",
              "mappings": [
                "x => y",
                "a => b"
              ]
            },
            "html_strip": {
              "type": "html_strip"
            }
          }

Sounds like everything is working as expected :)

I close the issue then, feel free to reopen it if more details needed.

Regards

All 4 comments

Hello @sdasun

yes it should, although I did not test with mappings. Did you try your solution ? is it triggering an error ?

Regards

I tried, I got this error. (Please note, I did have Unicode character in this xml file. I will double check it tonight and let you know.)

Premature end of data in tag analysis line 19
Line: 248
 {"exception":"[object] (Magento\\Framework\\Exception\\LocalizedException(code: 0): Invalid XML in file /usr/share/ngin
x/html/vendor/smile/elasticsuite/src/module-elasticsuite-core/etc/elasticsuite_analysis.xml:
expected '>'
Line: 25

Opening and ending tag mismatch: mappings line 25 and unparseable
Line: 25

Opening and ending tag mismatch: mappings line 25 and char_filter
Line: 26

expected '>'
Line: 27

Opening and ending tag mismatch: char_filters line 22 and analysis
Line: 246

Premature end of data in tag analysis line 19

Actually you have a typo at the closing "" tag. This is what is triggering the error.

I will try to go further by myself.

Ok so I tried with the following syntax :

    <char_filters>
        <char_filter name="html_strip" type="html_strip" language="default"/>
        <char_filter name="custom_mapper" type="mapping" language="default">
            <mappings>["x => y", "a => b"]</mappings>
        </char_filter>
    </char_filters>

Please note the "type=mapping" without the S.

And ran a reindex. Mapping is shown in Elasticsearch like this :

"char_filter": {
            "custom_mapper": {
              "type": "mapping",
              "mappings": [
                "x => y",
                "a => b"
              ]
            },
            "html_strip": {
              "type": "html_strip"
            }
          }

Sounds like everything is working as expected :)

I close the issue then, feel free to reopen it if more details needed.

Regards

Was this page helpful?
0 / 5 - 0 ratings

Related issues

emirajbbd picture emirajbbd  路  3Comments

JonathanBBD picture JonathanBBD  路  3Comments

surendiranganesan picture surendiranganesan  路  3Comments

gihovani picture gihovani  路  4Comments

shamoon picture shamoon  路  3Comments