Facet filtering broke after update, set_filter_query_fields not working anymore?

  • HaikoG
    Participant
    # 8 months, 1 week ago

    Hi,

    We’ve just updated to the latest version and are running into some unexpected behavior. I hope you can help us out on this one. We came from version 21.8, now on 22.2. We run on Solr, self hosted.
    In version 21.8 we added multiple query filters by using set_filter_query_fields() (see code below).
    Now in version 22.2 this does not work anymore. I can see the values in the solr_client object, but it never gets added to the request to Solr.

    Not only are our own query filters missing from the request, the facet filters as well. They’re visible in the solr client object, but never make it to the request. After some digging around in the code I found $search_engine_client->search_engine_client_add_filter(); which I can use for my own custom work. But that won’t fix the built in facet filters.
    How do I get the facet filtering working again?

    Code:

    add_filter(WPSOLR_Events::WPSOLR_FILTER_UPDATE_WPSOLR_QUERY, 'fq_solr_query', 998, 1);
    function fq_solr_query(WPSOLR_Query $wpsolr_query)
    {
        $current_query = $wpsolr_query->get_filter_query_fields();
        $current_query[] =  '-product_type_str:variable';
        $wpsolr_query->set_filter_query_fields($current_query);
        return $wpsolr_query;
    }

    Solr client object (partially):

    [wpsolr_query:protected] => 
        [wpsolr_filter_query:protected] => Array
            (
                [0] => -product_type_str:variable
            )
    wpsolr
    Keymaster
    # 8 months, 1 week ago

    Did you mean ‘product_type_str:variable’ instead of ‘-product_type_str:variable’ ?

    HaikoG
    Participant
    # 8 months, 1 week ago

    No the query is correct, but the query is not the issue. It all worked well before the update but not anymore.

    wpsolr
    Keymaster
    # 8 months, 1 week ago

    Please check that ‘-product_type’ is a custom field or a taxonomy selected in 2.2 (to be indexed), and in 2.4 (to be a facet).

    HaikoG
    Participant
    # 8 months, 1 week ago

    We add multiple query filters to the query using set_filter_query_fields().
    For example we filter in_stock items only by ‘_stock_i:[1 TO *]’ or search in a few product categories only, but those queries are not included in the request. The same goes for when filtering using the facets. In this request I’m using the facet filtering, a log on the get_filter_query_fields() returns

    Array
    (
        [0] => pa_kleur-van-het-product_str:Wit
    )

    But when you check out the request that is received by Solr, there is not mentioning of the FQ.
    We did not do any customizations on the facet filters, so we expected this to keep working..

    {facet.field={!key%3Dproduct_cat_str+ex%3Dfct_excl_product_cat_str}product_cat_str&facet.field={!key%3Dpa_merk_str+ex%3Dfct_excl_pa_merk_str}pa_merk_str&facet.field={!key%3Dcategories_str+ex%3Dfct_excl_categories_str}categories_str&facet.field={!key%3Dpa_beeldschermdiagonaal_str+ex%3Dfct_excl_pa_beeldschermdiagonaal_str}pa_beeldschermdiagonaal_str&facet.field={!key%3Dpa_inclusief-besturingssysteem_str+ex%3Dfct_excl_pa_inclusief-besturingssysteem_str}pa_inclusief-besturingssysteem_str&facet.field={!key%3Dpa_ingebouwde-luidsprekers_str+ex%3Dfct_excl_pa_ingebouwde-luidsprekers_str}pa_ingebouwde-luidsprekers_str&facet.field={!key%3Dpa_intern-geheugen_str+ex%3Dfct_excl_pa_intern-geheugen_str}pa_intern-geheugen_str&facet.field={!key%3Dpa_kleur-van-het-product_str+ex%3Dfct_excl_pa_kleur-van-het-product_str}pa_kleur-van-het-product_str&facet.field={!key%3Dpa_processorfamilie_str+ex%3Dfct_excl_pa_processorfamilie_str}pa_processorfamilie_str&facet.field={!key%3Dpa_processormodel_str+ex%3Dfct_excl_pa_processormodel_str}pa_processormodel_str&facet.field={!key%3Dpa_resolutie_str+ex%3Dfct_excl_pa_resolutie_str}pa_resolutie_str&facet.field={!key%3Dpa_totale-opslagcapaciteit_str+ex%3Dfct_excl_pa_totale-opslagcapaciteit_str}pa_totale-opslagcapaciteit_str&facet.field={!key%3Dpa_touchscreen_str+ex%3Dfct_excl_pa_touchscreen_str}pa_touchscreen_str&facet.field={!key%3Dpa_ssd-interface_str+ex%3Dfct_excl_pa_ssd-interface_str}pa_ssd-interface_str&facet.field={!key%3Dpa_aansluiting_str+ex%3Dfct_excl_pa_aansluiting_str}pa_aansluiting_str&json.nl=flat&fl=id,PID,type,meta_type_s,title,numcomments,comments,displaydate,displaymodified,*categories_str,author,*post_thumbnail_href_str,*post_href_str,snippet_s,_stock_str,_stock_i,shop_thumbnail_url,_thumbnail_id_i,_visibility_str,permalink,post_status_s,sku,ERP_productnr_s,pricelist_ids,product_type_str,content,score,_price_f&start=0&q.op=AND&f.pa_inclusief-besturingssysteem_str.facet.sort=index&sort=_stock_i+desc&fq={!tag%3Dfct_excl_type}type:(“product”)&fq=-post_status_s:(“draft”+OR+”pending”+OR+”trash”+OR+”future”+OR+”private”+OR+”auto-draft”)&fq=(((*:*+-product_visibility_str:*))+OR+(-product_visibility_str:(exclude-from-catalog)))&fq=(*:*+-is_excluded_s:[*+TO+*])+OR+is_excluded_s:(n)&rows=48&q=(*)&defType=edismax&omitHeader=true&qf=pa_model_t^10+pa_merk_t^10+title^10+_sku_t^10+product_cat_str^3+content+ean_code_str+pa_ean-code_str+pa_frequentie-van-processor_str+pa_geheugencapaciteit_str+pa_harde-schijf-omvang_str+pa_opslagcapaciteit_str+pa_compatibele-producten_str^0.1+_product_attributes_str^0.2+pa_beeldschermdiagonaal_str+pa_capaciteit_str+pa_intern-geheugen_str+pa_interne-opslagcapaciteit_str+pa_interne-ram_str+pa_maximale-beeldresolutie_str+pa_maximale-opslagcapaciteit_str+pa_maximale-resolutie_str+pa_maximum-resolutie_str+pa_opslag-schijfgrootte_str+pa_opslagcapaciteit-harde-schijf_str+pa_processorfamilie_str+pa_processormodel_str+pa_projector-native-resolution_str+pa_resolutie_str+pa_schermgrootte_str+pa_schermgrootte-display_str+pa_schermresolutie-tablet_str+pa_standaardcapaciteit_str+pa_totale-opslagcapaciteit_str+pa_type-processor_str&stats=true&facet.mincount=1&wt=json&facet=true&stats.field={!ex%3Dfct_excl__price_f}_price_f}

    wpsolr
    Keymaster
    # 8 months, 1 week ago

    The same goes for when filtering using the facets

    Do you mean that no filter is working at all, including the ones not customized in your code ?

    HaikoG
    Participant
    # 8 months ago

    Yes that is correct. All filters are broken. I can see them in the query object, but they are never added to the actual request to Solr

    HaikoG
    Participant
    # 8 months ago

    I also already tried to disable all the custom code and filtering, but that did not make a difference.

    wpsolr
    Keymaster
    # 8 months ago

    There must be some custom code remaining. How did you manage to get the solr queries traces?

    HaikoG
    Participant
    # 8 months ago

    I simply added an error_log(print_r($wpsolr_query,1)); to the start of execute_wpsolr_query() in /wpsolr-pro/wpsolr/core/classes/engines/class-wpsolr-abstractsearchclient.php

    That shows the filter is being added to the query object:
    [wpsolr_filter_query:protected] => Array
    (
    [0] => pa_kleur-van-het-product_str:Wit
    )

    I’ve enabled request logging in Solr to see the request that is received by Solr and that does not have this filter. It does filter on the selected product_cat_str, post_type, post_status_s

    We have collected all customizations in one single file which we have disabled during these tests, so I’m sure nothing interferes with the plugin defaults. We also do not run any caching on our development server.

    wpsolr
    Keymaster
    # 8 months ago

    Can you activate the WPSOLR logging in screen 2.1? It should show the query before being sent to Solr.

    HaikoG
    Participant
    # 8 months ago

    Yes, sure. This shows the same result. I you can share your email address I can send you the log if you want.

    wpsolr
    Keymaster
    # 8 months ago

    Then, you’ll have to debug the code unfortunately.
    You can start from method search_engine_client_add_filter_term() in file wpsolr-pro/wpsolr/core/classes/engines/solarium/class-wpsolr-searchsolariumclient.php

    Check that your filters are called in that method.

    HaikoG
    Participant
    # 8 months ago

    Wait.. we purchased this plugin.. now when it doesn’t work it’s up to us to dig around in the code and fix things?

    HaikoG
    Participant
    # 8 months ago

    This is built-in functionality that doesn’t work.. We are not calling any filters?

Viewing 15 posts - 1 through 15 (of 16 total)

You must be logged in to reply to this topic.