Add Asciifolding filter search to ElasticSearch

fabrice.dhuicque
fabrice.dhuicque Spryker Solution Partner Posts: 18 πŸ§‘πŸ»β€πŸš€ - Cadet

Hey here,

For our catalog search, we need to ignore accents. I can easily add the fuzzyquery filter to my search, but I don't have relevant result. I think, the perfect filter should be the Asciifolding, but it seems not to be implemented. How could I add this native ES filter to my Spryker project?!

Thank you for all!

Best Answer

  • Hidran Arias
    Hidran Arias Senior Technical Trainer Sprykee Posts: 81 πŸ› - Council (mod)
    Answer βœ“

    You can modify the file src/Pyz/Shared/Search/Schema/page.json

    to add your filter in the filter array in the index settings.

    • Delete an index : console elasticsearch:index:delete namespace_store_indexname
    • console search:setup:sources
    • console search:setup:source-map
    • (Execute vendor/bin/console publish:trigger-events to reindex all your data)

    After running the search:setup:source-map command, a helper class is autogenerated for every installed index. You can find these classes under the \Generated\Shared\Search namespace


Answers

  • Hidran Arias
    Hidran Arias Senior Technical Trainer Sprykee Posts: 81 πŸ› - Council (mod)
    Answer βœ“

    You can modify the file src/Pyz/Shared/Search/Schema/page.json

    to add your filter in the filter array in the index settings.

    • Delete an index : console elasticsearch:index:delete namespace_store_indexname
    • console search:setup:sources
    • console search:setup:source-map
    • (Execute vendor/bin/console publish:trigger-events to reindex all your data)

    After running the search:setup:source-map command, a helper class is autogenerated for every installed index. You can find these classes under the \Generated\Shared\Search namespace


  • fabrice.dhuicque
    fabrice.dhuicque Spryker Solution Partner Posts: 18 πŸ§‘πŸ»β€πŸš€ - Cadet

    Thank you very much, I will test that as I can, I'll tell you if everything is ok ;)

  • mikko.ropanen
    mikko.ropanen Spryker Solution Partner Posts: 27 ✨ - Novice

    Using this to bring up my suggestion that the ES/OS images should be updated:

    (this is not even totally unrelated; you'll probably find that ICU analysis would be really convenient :)

  • fabrice.dhuicque
    fabrice.dhuicque Spryker Solution Partner Posts: 18 πŸ§‘πŸ»β€πŸš€ - Cadet

    @Hidran Arias , thanks a lot, that works perfectly :)

  • Hidran Arias
    Hidran Arias Senior Technical Trainer Sprykee Posts: 81 πŸ› - Council (mod)

    That's great news!

  • Fred Jung
    Fred Jung Spryker Customer Posts: 24 ✨ - Novice
    edited July 24

    Just in case you are not aware of the consequences - be careful running this in production enviroment!

    This will wipe the whole search until rebuilding the index πŸ˜‚

  • Hidran Arias
    Hidran Arias Senior Technical Trainer Sprykee Posts: 81 πŸ› - Council (mod)

    It's like: " Not to try at home with your kids" !

  • mikko.ropanen
    mikko.ropanen Spryker Solution Partner Posts: 27 ✨ - Novice

    I have once managed to update the ES settings and mappings from page.json without deleting the whole index first, but cannot remember how :'(

    Technically it should be possible by closing the index, updating, and re-opening, but there was something that needed to be changed in code...

  • fabrice.dhuicque
    fabrice.dhuicque Spryker Solution Partner Posts: 18 πŸ§‘πŸ»β€πŸš€ - Cadet

    I did delete the whole index in preprod environment, indeed, rebuild all search is very long, almost an half day… So, if can't do this without deleting all indexes, I will do that during the weekend in prod environment, as a B2B platform, that won't be annoying :)