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

Unable To Search Multiple Select Attribute Code in Store Frontend "Your search returned no results." #94

Closed
acidreian666 opened this issue Aug 15, 2016 · 6 comments
Assignees
Labels
Milestone

Comments

@acidreian666
Copy link

Preconditions

  1. Magento 2.1
  2. ElasticSuite 2.2dev & elasticserver running.

Steps to reproduce

  1. Create a New Attribute Select Attribute Type "Multiple Select"
  2. Assign a few Options in the Admin & Default Store View Box's
  3. Set in Storefront Properties "Use in Search" Select Yes & Save Attribute.
  4. Add that new Attribute to an Attribute Set Mine was Default Set.
  5. Finally Reindex/Clear Cache
  6. Create new product using a Attribute Set you added your New Multiple Select Attribute too Selecting one or all the attributes that you added and save the Product.
  7. Reindex & Flush Cache again.

Expected result

  1. Search Attribute from the Multiple Select Attribute and Display The New Product we just created.

Actual result

  1. "Your search returned no results."

During the Search Autocomplete shows the new Product but if you Simply search the Attribute no products will be displayed. This issue only occurs when using the Multiple Select Attribute Option.

Proof of error I Recreated a Attribute using Text Field and entered text and that was searchable but when setting up a site filtering through text fields just isn't probable

Something is broken between the Displayed search and the autocomplete.

@romainruaud
Copy link
Collaborator

I confirm the issue.

I am investigating on this one and will try to provide a fix quickly.

Regards.

@acidreian666
Copy link
Author

acidreian666 commented Aug 19, 2016

@romainruaud I can Also Confirm this issue is with using a Dropdown Box & Multi select & possible the other options.

The issue below may or may not be relevant to #94 but the issue below is a core Magento2 issue #6253
Bug 2
Step1. Add 5 options to Multi Select or a Dropdown box.
Step2. Index and Clear cache.
Step3. Then delete lets say number 2 or 3 of the attributes click save it will save.
Step4. Somethings broken because then your not able to save any changes to anything in the "Manage Labels" or "Storefront Properties" Now this maybe an magento 2.1 bug as i have not tested it against a Vanilla Magento 2.1.

Confirming that this issue is a Magento 2 core issue going to be posting new issue on Magento2.

@romainruaud
Copy link
Collaborator

Using the Luma catalog, I use the "Climate" attribute.

If I search a first time for "hoodie", I see there are 20 hoodies having the "Spring" value for the "Climate" attribute.

If I search again for "spring hoodie" => no result.
If I search only for "spring" => "No exact results found for: 'spring'. The displayed items are the closest matches."

So I decided to look at the term vector query which is triggered to determine if we have to process a fuzzy search or an exact search.

Eg the following term vector query : {"doc":{"spelling":"spring"}}

Which results in :

{
  "_index": "magento2_default_catalog_product_20160913_153628",
  "_type": "product",
  "_version": 0,
  "found": true,
  "took": 2,
  "term_vectors": {
    "spelling": {
      "field_statistics": {
        "sum_doc_freq": 13182,
        "doc_count": 187,
        "sum_ttf": 17148
      },
      "terms": {
        "spring": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 0,
              "start_offset": 0,
              "end_offset": 6
            }
          ]
        }
      }
    },
    "spelling.phonetic": {
      "field_statistics": {
        "sum_doc_freq": 10882,
        "doc_count": 187,
        "sum_ttf": 17148
      },
      "terms": {
        "SPRN": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 0,
              "start_offset": 0,
              "end_offset": 6
            }
          ]
        }
      }
    },
    "spelling.whitespace": {
      "field_statistics": {
        "sum_doc_freq": 13532,
        "doc_count": 187,
        "sum_ttf": 17148
      },
      "terms": {
        "spring": {
          "term_freq": 1,
          "tokens": [
            {
              "position": 0,
              "start_offset": 0,
              "end_offset": 6
            }
          ]
        }
      }
    }
  }
}

=> There is no "doc_count" for the term "spring" in term vector results.
=> So we consider it is not present in the index, and process a fuzzy query instead of an exact one.

The question is now : why ?

Here is the mapping of this attribute :

"option_text_climate" : {
            "type" : "string",
            "analyzer" : "standard",
            "fielddata" : {
              "format" : "lazy"
            },
            "fields" : {
              "shingle" : {
                "type" : "string",
                "analyzer" : "shingle",
                "fielddata" : {
                  "format" : "lazy"
                }
              },
              "untouched" : {
                "type" : "string",
                "index" : "not_analyzed",
                "fielddata" : {
                  "format" : "doc_values"
                }
              },
              "whitespace" : {
                "type" : "string",
                "analyzer" : "whitespace",
                "fielddata" : {
                  "format" : "lazy"
                }
              }
            },
            "copy_to" : [ "search" ]
          }

Here is also an example of product in ES with this field :

          "option_text_climate": [
            "Spring",
            "Windy"
          ],

Which seems similar to other attributes like "color". And "blue hoodie" is working properly, also does the term vector query for "blue" or "blue hoodie" => is has doc count.

WARNING : "blue hoodie" seems to be a false positive : "blue" is in the product description.

=> After removing description from the indexable fields, I have no results for "blue hoodie" !!!
=> So the value of "color" is neither processed correctly !

@romainruaud
Copy link
Collaborator

romainruaud commented Sep 15, 2016

I think I got it.

The term vector query is processed on the "spelling" field of the index.

As seen above, problematic fields are NOT copied to "spelling".

This is due to this piece of code : https://github.com/Smile-SA/elasticsuite/blob/master/src/module-elasticsuite-catalog/Model/Eav/Indexer/Fulltext/Datasource/AbstractAttributeData.php#L182

option's text attributes are arbitrary set to "is_used_in_spellcheck:false".

Maybe we should consider using the value of the attribute they are related to. This should be also valid for other properties like "is_used_in_autocomplete" or even "is_searchable" which is forced to true even if we do not plan to search on this attribute.

@romainruaud
Copy link
Collaborator

@afoucret there is a proposal of fix in PR #116

Let me know.

@romainruaud romainruaud assigned afoucret and unassigned romainruaud Sep 20, 2016
@romainruaud
Copy link
Collaborator

the PR has been merged.

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