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 doesn’t work. #970

Closed
jsmw opened this issue Jun 22, 2018 · 17 comments
Closed

Partial search doesn’t work. #970

jsmw opened this issue Jun 22, 2018 · 17 comments

Comments

@jsmw
Copy link

jsmw commented Jun 22, 2018

Partial search doesn’t work. Debugged with ElasticSearch Head Extension the same query returns results for the whole word and no results for part of the same word. Checked ElasticSearch index and product is there. We tried to change 'fuzziness' to 2 and' prefix_length' to 0 then we get too many products that are not related to the searched term.

Preconditions

Magento Version : 2.2.4
ElasticSuite Version : 2.5.0
Environment : Developer mode
Elasticsearch Version: 5.2.2

Third party modules :
Shopial_Facebook
Sofort_Payment
Ves_Megamenu
Vertex_Tax
Ves_PageBuilder
Ves_BaseWidget
Ves_All
Ho_Templatehints
AvS_ScopeHint
Bold_OrderComment
Klarna_Core
Amazon_Core
FireGento_MageSetup
Klarna_Ordermanagement
Amazon_Login
Klarna_Kp
Dotdigitalgroup_Email

Steps to reproduce

  1. Search for 'prof' and press enter
  2. On the search result page there is no result, although there are many products that contain the searched term in the name

Expected result

  1. Search for 'prof' and press enter
  2. The products are listed on the search page

Actual result

  1. Search for 'prof' and press enter
  2. No products are found

search_result

3. There are products on the category page that contain the searched term

category_page

@afoucret
Copy link
Contributor

Partial search is not a feature we plan for now.
Maybe we could add it when we will refactor the spellchecker.

The option you have changed are only useful if you want to change the typo tolerance.

I would be glad to review some code / PR, if you think it is an important feature and you are able to deliver the feature.

@TimQSO
Copy link

TimQSO commented Oct 17, 2018

This is, in my opinion, one of the most important missing features. Customers are just expecting this to work and don't understand that they don't get any results while searching for something while filling out a partial word.

@thampe
Copy link
Contributor

thampe commented Feb 20, 2020

Hi,

are there any new developments regarding this issue?

Thanks!

@TimQSO
Copy link

TimQSO commented Feb 20, 2020

I gave up on it and switched to a paid version of Amasty.

@thampe
Copy link
Contributor

thampe commented Mar 4, 2020

Mee to. We also switched to a paid plugin.

@elvinristi
Copy link
Contributor

There's no need for Smile to do that. you have possibility to extend xml-files in your project and make some minor code improvements.

just

  • add new filter to etc/elasticsuite_analysis.xml i.e.
<filters>
        <filter name="reference_ngram" type="edge_ngram" language="default">
            <min_gram>3</min_gram>
            <max_gram>20</max_gram>
            <token_chars></token_chars>
        </filter>
<filters>
  • add new analyser to etc/elasticsuite_analysis.xml which contains this new filter, i.e.
    <analyzers>
        <analyzer name="ngram_test" tokenizer="standard" language="default">
            <filters>
                <filter ref="ascii_folding" />
                <filter ref="lowercase" />
                <filter ref="word_delimiter" />
                <filter ref="elision" />
                <filter ref="reference_ngram" />
                <filter ref="trim" />
            </filters>
            <char_filters>
                <char_filter ref="html_strip" />
            </char_filters>
        </analyzer>
    </analyzers>
  • assign product.name to use this analyser etc/elasticsuite_indices.xml

    <index identifier="catalog_product" defaultSearchType="product">
        <type name="product" idFieldName="entity_id">
            <mapping>

                <field name="name" type="text">
                    <isSearchable>1</isSearchable>
                    <isUsedInSpellcheck>1</isUsedInSpellcheck>
                    <isFilterable>0</isFilterable>
                    <defaultSearchAnalyzer>ngram_test</defaultSearchAnalyzer>
                </field>
            </mapping>
        </type>
    </index>
  • i.e. patch src/module-elasticsuite-core/Search/Request/Query/Fulltext/QueryBuilder.php::getCutoffFrequencyQuery to include name in $queryParams

  • clean cache

  • full reindex catalogsearch

disclaimer. this is just example - just plain copy-paste might not help you. you need to be knowing what you are doing and you need to be DEV to understand this.

@romainruaud
Copy link
Collaborator

God bless you @elvinristi 🙏

Thanks for supporting this extension and taking some time about how extending it :)

@joachimVT
Copy link

joachimVT commented Sep 26, 2022

Hi

I added a new filter and analyser to elasticsuite_analysis.xml:

<?xml version="1.0"?>
<analysis xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
          xsi:noNamespaceSchemaLocation="urn:magento:module:Smile_ElasticsuiteCore:etc/elasticsuite_analysis.xsd">
    <filters>
        <filter name="reference_ngram" type="edge_ngram" language="default">
            <min_gram>3</min_gram>
            <max_gram>20</max_gram>
            <token_chars></token_chars>
        </filter>
    </filters>

    <analyzers>
        <analyzer name="ngram_test" tokenizer="standard" language="default">
            <filters>
                <filter ref="ascii_folding" />
                <filter ref="lowercase" />
                <filter ref="word_delimiter" />
                <filter ref="elision" />
                <filter ref="reference_ngram" />
                <filter ref="trim" />
            </filters>
            <char_filters>
                <char_filter ref="html_strip" />
            </char_filters>
        </analyzer>
    </analyzers>
</analysis>

I assigned product.sku to use this analyser etc/elasticsuite_indices.xml

<?xml version="1.0"?>
<indices xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
         xsi:noNamespaceSchemaLocation="urn:magento:module:Smile_ElasticsuiteCore:etc/elasticsuite_indices.xsd">
    <index identifier="catalog_product" defaultSearchType="product">
        <type name="product" idFieldName="entity_id">
            <mapping>
                <field name="sku" type="text">
                    <isSearchable>1</isSearchable>
                    <isUsedForSortBy>1</isUsedForSortBy>
                    <isUsedInSpellcheck>1</isUsedInSpellcheck>
                    <isFilterable>1</isFilterable>
                    <defaultSearchAnalyzer>ngram_test</defaultSearchAnalyzer>
                </field>
            </mapping>
        </type>
    </index>
</indices>

Cleaned cached an did a full reindex catalogsearch, with no result. Searching for sku sln25 should show product with sku sln25025 , search results are empty.
Any ideas why this isn't working ?

@LucScu
Copy link

LucScu commented Jul 17, 2023

@joachimVT do you resolved?

@romainruaud
Copy link
Collaborator

We added the ability to assign an ngram analyzer to every attribute through the backoffice.

So this issue is solved now.

Give a try to :

  • upgrade to Elasticsuite 2.10.17.1 / 2.11.3.1
  • configure any attribute you want to use for partial matching to use the "standard_edge_ngram" analyzer through the backoffice since it's shipped with Elasticsuite now
  • enable the "Use default analyzer in exact matching filter query" in the **Elasticsuite > Relevance configuration" menu
  • Proceed with a full reindex

@LucScu
Copy link

LucScu commented Jul 17, 2023

@romainruaud you are incredible :)
i'm studying how elasticsearch works, it is very impressive, do you think is possible with this tokenizer
https://www.elastic.co/guide/en/elasticsearch/reference/current/analysis-edgengram-tokenizer.html
and this string
"Quick Fox"
add the to the created token
[ Q, Qu ]
the below tokens
[ u, ui, i, ic, c, ck, k] ?

@romainruaud
Copy link
Collaborator

edge_ngram will create "Q, Qu, Qui, Quic, Quick, B, Br, Bro, Brow, Brown".

ngram will create the same but also "u, ui, i, ic, c..." etc... as you suggest.

imho, edge_ngram is better and enough in our case.

@LucScu
Copy link

LucScu commented Jul 17, 2023

yes, exactly what i'm searching, i'm testing it, i give you a feedback. thx you very much

@LucScu
Copy link

LucScu commented Jul 21, 2023

@romainruaud it works for every field, except sku, even if i change to "standard_edge_ngram" it continues to search on sku.relevance.
I think i have to override elasticsuite_indices.xml and change here directly.
Great job :)

@romainruaud
Copy link
Collaborator

@LucScu you're right, the xml always has precedence.

@avstudnitz
Copy link

@romainruaud Thanks a lot! It works like a charm.

@romainruaud
Copy link
Collaborator

I'm gonna close this issue because the edge_ngram analyzer can be used for any field now, from the XML file, or in the back-office.

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

9 participants