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

RFC : Search products by SKU #100

Closed
fcapovilla opened this issue Aug 25, 2016 · 7 comments
Closed

RFC : Search products by SKU #100

fcapovilla opened this issue Aug 25, 2016 · 7 comments

Comments

@fcapovilla
Copy link

Searches by SKU currently return 0 results on our Magento 2.1 instances with Elasticsuite 2.2.
Searching for names or other custom attribute values seem to return the correct results.

The "Use in search" configuration is currently activated on our "sku" product attribute, but it seems to have no effect on our results.

The same problem can be observed on the demo store (http://demo.magento-elastic-suite.io/), although I don't know if the SKU attribute was configured to be used in searches there.

Our current configuration is :

  • Elasticsuite 2.2.0-alpha2
  • Magento 2.1.0
  • Elasticsearch 2.3.5
@southerncomputer
Copy link
Contributor

Because SKU is not mapped correctly!
"sku" : {
"type" : "string",
"index" : "not_analyzed",
"fielddata" : {
"format" : "doc_values"
}
},
"spelling" : {
"type" : "string",
"fields" : {
"phonetic" : {
"type" : "string",
"analyzer" : "phonetic"
},
"shingle" : {
"type" : "string",
"analyzer" : "shingle"
},
"whitespace" : {
"type" : "string",
"analyzer" : "whitespace"
}
},
"analyzer" : "standard"
},

Compared to attribute sprc_sku:

"sprc_sku_code" : {
"type" : "string",
"fielddata" : {
"format" : "lazy"
},
"fields" : {
"edge_ngram_front" : {
"type" : "string",
"fielddata" : {
"format" : "lazy"
},
"analyzer" : "edge_ngram_front"
},
"phonetic" : {
"type" : "string",
"fielddata" : {
"format" : "lazy"
},
"analyzer" : "phonetic"
},
"shingle" : {
"type" : "string",
"fielddata" : {
"format" : "lazy"
},
"analyzer" : "shingle"
},
"untouched" : {
"type" : "string",
"index" : "not_analyzed",
"fielddata" : {
"format" : "doc_values"
}
},
"whitespace" : {
"type" : "string",
"fielddata" : {
"format" : "lazy"
},
"analyzer" : "whitespace"
}
},
"copy_to" : [ "search", "spelling", "autocomplete" ],
"analyzer" : "standard"
},

Do you see what is missing?

@southerncomputer
Copy link
Contributor

I believe the built-in indices that are not user-added are supposed to be picked up by an xml file but they are not being processed could be ElasticsuiteCore/etc/elasticsuite_indices.xml

you can force all fields to be searchable by modifying (ghetto-fix):

in module-elasticsuite-core/Index/Mapping/Field.php

Change:
private $config = [ 'is_searchable' => false, 'is_filterable' => true, 'is_used_for_sort_by' => false, 'is_used_in_spellcheck' => false, 'is_used_in_autocomplete' => false, 'search_weight' => 1, ];

to:
private $config = [ 'is_searchable' => true, 'is_filterable' => true, 'is_used_for_sort_by' => false, 'is_used_in_spellcheck' => false, 'is_used_in_autocomplete' => false, 'search_weight' => 1, ];

which will default all fields not specified to be is_searchable ! I am not sure if the other fields could be tweaked to perform better SKU searching but this tweak does work temporarily!

@romainruaud
Copy link
Collaborator

romainruaud commented Sep 15, 2016

My proposal of implementation :

1st step :

  • Create a technical filter, like this :

      <filter name="technical_delimiter" type="word_delimiter" language="default">
              <generate_word_parts>0</generate_word_parts>
              <catenate_words>0</catenate_words>
              <catenate_numbers>0</catenate_numbers>
              <catenate_all>0</catenate_all>
              <split_on_case_change>0</split_on_case_change>
              <split_on_numerics>0</split_on_numerics>
              <preserve_original>1</preserve_original>
          </filter>
    

This will prevent fields using this analyzer to be splitted between word and number, hyphens ...

  • Then create a technical analyzer, like this :

      <analyzer name="technical" tokenizer="whitespace" language="default">
              <filters>
                  <filter ref="technical_delimiter" />
                  <filter ref="lowercase" />
                  <filter ref="ascii_folding" />
                  <filter ref="trim" />
                  <filter ref="edge_ngram_front" />
              </filters>
              <char_filters>
                  <char_filter ref="html_strip" />
              </char_filters>
          </analyzer>
    

2nd step :

  • Add a way to set on an attribute if it's a "technical reference" or not (eg: in BO attribute edit).
  • If the attribute is detected as being a technical reference during indexing, append the technical analyzer.

=> Tested on SKU attribute, this is working fine on Luma catalog, with SKUs being something like "MH09". Still need to test for EAN13 but should also work.

@afoucret feel free to tell me what you think about it.

@afoucret
Copy link
Contributor

This one is solved by PR #300.
It is now merged into the 2.4.x branch and will be part of our next major release (2.4.0).

@blewinsky
Copy link

@afoucret i see that this PR is for 2.4.x but do you have a fix fro current version 2.3.x?

@PieterCappelle
Copy link

Can we use 2.4.0 already in production? When will 2.4.0 be available?

@romainruaud
Copy link
Collaborator

@PieterCappelle the release date of 2.4.0 is "soon". We are currently finishing our testing procedures internally, having updated the README, cleaning the documentation etc ...

You can consider it is actually in RC state, so feel free to use it in production (but with caution) if you want.

But beware, 2.4.0 version will be supporting only Magento 2.2. This is especially due to the update of their unit testing tools, which does not allow to run properly the unit testing on Magento 2.1 with Elasticsuite 2.4.

Best regards.

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

No branches or pull requests

6 participants