Facet count is wrong when a text query is used

  • HaikoG
    Participant
    # 3 weeks, 2 days ago

    Hello,

    I’ve successfully set up WPSolr with a local Solr engine. Had some problems in the beginning, but was able to solve it with your help two weeks ago.

    Now we’re ready for testing and noticed a strange result when search text (?s=gerard&post_type=product)
    I get no results, which is expected as there is no product with “Gerard” in the title or description, but I do get a list of facets with counts on them. Clicking a facet, gives me 0 results as well.

    Replicating the query in the Solr webinterface (fl=*,score&fq=pricelist_ids:”1″&fq=type:(“product”)&q=text:(gerard)&rows=20) also shows no results. So what’s going on that it is showing facets for a query with 0 results?

    The counts on the facets are not the total of the facets (for example I get (3) for the color black on the text query, and 3568 black items when not using a text search) so it is filtering on something somehow..

    I’ve already tried disabling all custom code running on the website, which did not help.

    wpsolr
    Keymaster
    # 3 weeks, 2 days ago

    For which WPSOLR and Solr versions?

    HaikoG
    Participant
    # 3 weeks, 2 days ago

    That’s WPSOLR PRO 21.6 and Solr 7.3.1

    wpsolr
    Keymaster
    # 3 weeks, 2 days ago

    It could be that your search returns post types other than “products”, but your theme cannot display them.

    Did you activate our WooCommerce extension?

    HaikoG
    Participant
    # 3 weeks, 2 days ago

    Yes, the woocommerce extension is activated.

    Is there a way to check the raw results coming from Solr? If I print_r the solr_query from WPSOLR_Events::WPSOLR_ACTION_SOLARIUM_QUERY I do see queryfilters for type:product

    • This reply was modified 3 weeks, 2 days ago by  wpsolr. Reason: removed long print_r
    wpsolr
    Keymaster
    # 3 weeks, 2 days ago

    You can debug in WPSOLR_Query::get_posts()

    HaikoG
    Participant
    # 3 weeks, 1 day ago

    I tried looking in the code, but it is unclear to me how to do that.
    When looking at the query though, I do see Query Filters for type:product

    [filterQueries:protected] => Array
    (
    [authorized indexed types] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => type:(“product”)
    [options:protected] => Array
    (
    [query] => type:(“product”)
    [key] => authorized indexed types
    )

    )

    [bad_statuses] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => -post_status_s:(“draft” OR “pending” OR “trash” OR “future” OR “private” OR “auto-draft”)
    [options:protected] => Array
    (
    [key] => bad_statuses
    [query] => -post_status_s:(“draft” OR “pending” OR “trash” OR “future” OR “private” OR “auto-draft”)
    )

    )

    [pricelist_ids:”1″] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => pricelist_ids:”1″
    [options:protected] => Array
    (
    [key] => pricelist_ids:”1″
    [query] => pricelist_ids:”1″
    [tag] =>
    )

    )

    [type:”product”] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => type:”product”
    [options:protected] => Array
    (
    [key] => type:”product”
    [query] => type:”product”
    [tag] =>
    )

    )

    [woocommerce type:product] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    [] => 1
    )

    [query:protected] => type:”product”
    [options:protected] => Array
    (
    [key] => woocommerce type:product
    [query] => type:”product”
    [tag] =>
    )

    )

    [woocommerce catalog visibility] => Solarium\QueryType\Select\Query\FilterQuery Object
    (
    [tags:protected] => Array
    (
    )

    [query:protected] => ((*:* -product_visibility_str:*) OR -product_visibility_str:(exclude-from-search))
    [options:protected] => Array
    (
    [key] => woocommerce catalog visibility
    [query] => ((*:* -product_visibility_str:*) OR -product_visibility_str:(exclude-from-search))
    )

    )

    HaikoG
    Participant
    # 3 weeks, 1 day ago

    Ok, I found a clue 🙂

    I think search suggestions has something to do with this. I found this in the query object
    [corrections:protected] => Array
    (
    [gerard] => gehard
    )

    Gehard is Dutch for hardened which is actually a word that’s used in our descriptions. When searching for ‘Gehard’ I get results and the exact same facets and facet counts. This looks like the facets are using the correction, but the results are not.

    What can I do to let the search use the correction as well?

    wpsolr
    Keymaster
    # 3 weeks, 1 day ago

    Thanks. I could finally reproduce your issue.

    Settings:
    – “Did you mean activated” in screen 2.1
    – “Use my own theme template” in screen 2.1

    With those settings, one can get facets on mispelled keywords, while the results remain empty.

    I’m investigating.

    wpsolr
    Keymaster
    # 3 weeks, 1 day ago

    It’s a complex problem, and I will no be able to deliver a quick fix.

    The fix will be delivered in the next release 21.8. Probably in the next 2 weeks.

    HaikoG
    Participant
    # 3 weeks, 1 day ago

    I just found that when I enable ‘Use fuzzy keyword matches in results’ I do get the results, only the user has no way of knowing their search keyword was changed as I can’t get that text to show up

Viewing 11 posts - 1 through 11 (of 11 total)

You must be logged in to reply to this topic.