Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Partial search for WooCommerce SKU with numbers in it #2076

Closed
mathiasoem opened this issue Feb 10, 2021 · 4 comments
Closed

Partial search for WooCommerce SKU with numbers in it #2076

mathiasoem opened this issue Feb 10, 2021 · 4 comments
Assignees
Labels

Comments

@mathiasoem
Copy link

I have a WooCommerce store where i would like to be able to search for partial hits on product SKU's.
This works fine when the search query does not contain a number.

Searching for "FI-PH" returns all products with sku's starting with "FI-PH", e.g. FI-PH034, FI-PH023 and so on.

But when adding numbers to the search query, e.g. "FI-PH0" no results are returned.

When hitting the full SKU results are also returned, e.g. searching for "FI-PH023" returns the product with SKU "FI-PH023".

I have tried adding edge_ngram to the default filters, but then no results are returned at all.

Any help would be appreciated.

@felipeelia
Copy link
Member

Hi @mathiasoem ,

As you probably have already figured out, to achieve that you will need to:

  1. Add the ngram field to the mapping somehow
  2. Reindex everything
  3. Change the query sent to Elasticsearch in a way to include the new ngram field.

Can you please share the code you've used for #1 and #3 and also confirm you did #2? Thanks!

@aronvandervalk
Copy link

@mathiasoem I have the exact same issue, where partial matching of a SKU with numbers in it does not work. Do you have an example of the implementation of the ngram field?

@mathiasoem
Copy link
Author

I experienced so many compatibility issues that I ended up completely disabling elasticpress, so I can't tell you what I did. Disabling it actually resulted in alle of my queries being faster, somehow.

@aronvandervalk
Copy link

@mathiasoem Thanks for your reply. Sorry to hear it did not work out.

@felipeelia Could you create an example of an ngram mapping filter on a custom ACF field?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants