• Resolved hpr78

    (@hpr78)


    I have a custom post_type with custom taxonomy.

    Post-ID 180 with categories 35 and 15.
    Post-ID 247 only in category 26.

    My tax_query should return Post-ID 180 only.

    Relevanssi disabled WP_Query work as expected, Relevanssi enabled no results.

    Array
    (
        [post_status] => publish
        [post_type] => Array
            (
                [0] => kb
            )
    
        [s] => xxx
        [tax_query] => Array
            (
                [relation] => OR
                [0] => Array
                    (
                        [taxonomy] => kb_category
                        [field] => term_id
                        [terms] => Array
                            (
                                [0] => 35
                                [1] => 15
                            )
    
                        [operator] => AND
                    )
    
                [1] => Array
                    (
                        [taxonomy] => kb_category
                        [field] => term_id
                        [terms] => Array
                            (
                                [0] => 26
                                [1] => 15
                            )
    
                        [operator] => AND
                    )
    
            )
    )

    After initializing $args i call

    
    $query = new WP_Query( $args );
    relevanssi_do_query( $query );
    

    Version: 4.13.2

    Settings:
    Default operator: AND
    Fallback: Disabled
    Default order: Relevancy
    Keyword matching: Partial words
    Weight: 1, 5, 0.75, 1, 1
    Boos: Enabled
    Admin: Disabled
    Respect exclude_from_search: Enabled
    Throttle: Enabled

    When i search only with one tax_query entry i got the result

    Array
    (
        [post_status] => publish
        [post_type] => Array
            (
                [0] => kb
            )
    
        [s] => xxx
        [tax_query] => Array
            (
                [0] => Array
                    (
                        [taxonomy] => kb_category
                        [field] => term_id
                        [terms] => Array
                            (
                                [0] => 35
                                [1] => 15
                            )
    
                        [operator] => AND
                    )
    
            )
    )
Viewing 3 replies - 1 through 3 (of 3 total)
  • Thread Starter hpr78

    (@hpr78)

    P.s: or is that only in pro Version possible?

    Plugin Author Mikko Saari

    (@msaari)

    No, the tax_query handling is the same in the free Relevanssi and the Premium version. That won’t help.

    Looks like you’ve found a bug in Relevanssi tax_query parsing. This particular combination of AND and OR relations does not currently work in Relevanssi. I’ll look into this, but I can’t promise any results fast.

    Meanwhile one way to deal with this is to ignore the tax_query in searching and filter out the unwanted posts with a relevanssi_hits_filter filter function.

    • This reply was modified 3 years, 8 months ago by Mikko Saari.
    Plugin Author Mikko Saari

    (@msaari)

    I figured out a way to fix this, so next version of Relevanssi should handle tax_queries like this much better.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘tax_query relation not work’ is closed to new replies.