Hello,
I had to enhance a project which works with ElasticSearch 7.3 (ES).

I found a problem with autocomplete when I used ngram on fulltext fields.

ES have a parameter called 'max_ngram_diff' which define the maximum difference between min_ngram and max_ngram.
But the default value is 1 and can't be changed throught Drupal. So, it's actually impossible to define for example min_gram = 3 and max_gram = 10 to say to the tokenizer to split more efficiantly.

I have added a new field into "Ngram configuration" tab, on "edit index" form to do that. After setting this new field, the parameter max_ngram_diff is passed to index configuration on ES server.

This way, autocomplete's results are more pertinents.

I propose a patch to enhance ngram configuration directly on Drupal.

Thanks !

Comments

laand created an issue. See original summary.

grimreaper’s picture

Assigned: striknin » Unassigned
Status: Patch (to be ported) » Needs review
thursday_bw’s picture

Is that backwards compatible with older versions of elasticsearch?

Also you can model or add to the existing javascript test to add some tests to that field.
This test: https://git.drupalcode.org/project/elasticsearch_connector_autocomp/-/bl...

If this is a blocker for new versions of elasticsearch then would be great to get it through.

thursday_bw’s picture

Status: Needs review » Needs work
thursday_bw’s picture

StatusFileSize
new107.74 KB

screenshot of patch
As for the patch, it failes coding standards due to white space at the end of a few lines. You can see them clearly in read in this screenshot.

I can take care of those easy enough on merge, but is worth noting to avoid them in the future.

I'd love to get this through. I've been contemplating for a long time that this module may evolve into more than just ngram config.
That's a conversation for a different issue.

thursday_bw’s picture

Issue tags: +Needs tests
bartlangelaan’s picture

StatusFileSize
new2.2 KB

We have been using this patch in production for a few months now, flawlessly.

Attached is a new patch, that also contains the configuration schema for the third_party_settings.
This way, the config is formatted nicely, and no errors are shown when using config_inspector.

I have also removed the whitespace changes.

ralphvdhoudt’s picture

Status: Needs work » Reviewed & tested by the community
StatusFileSize
new2.7 KB

Path #7 added the schema, only extending the search_api.index.* schema did not work correctly

Updated the config schema to work with third_party_settings with their own config