Title: calebaq's Replies | WordPress.org

---

# calebaq

  [  ](https://wordpress.org/support/users/calebaq/)

 *   [Profile](https://wordpress.org/support/users/calebaq/)
 *   [Topics Started](https://wordpress.org/support/users/calebaq/topics/)
 *   [Replies Created](https://wordpress.org/support/users/calebaq/replies/)
 *   [Reviews Written](https://wordpress.org/support/users/calebaq/reviews/)
 *   [Topics Replied To](https://wordpress.org/support/users/calebaq/replied-to/)
 *   [Engagements](https://wordpress.org/support/users/calebaq/engagements/)
 *   [Favorites](https://wordpress.org/support/users/calebaq/favorites/)

 Search replies:

## Forum Replies Created

Viewing 4 replies - 1 through 4 (of 4 total)

 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Relevanssi - A Better Search] No results when using complex tax queries](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/)
 *  Thread Starter [calebaq](https://wordpress.org/support/users/calebaq/)
 * (@calebaq)
 * [3 years ago](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/#post-16790702)
 * That’s what I was thinking about doing next and was trying to figure out the 
   best way to do it. I’ll work through some ideas on Monday and see what I can 
   come up.
 * Thanks for taking a look at this! If you need any specific information from me,
   just let me know. Happy to help anyway I can.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Relevanssi - A Better Search] No results when using complex tax queries](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/)
 *  Thread Starter [calebaq](https://wordpress.org/support/users/calebaq/)
 * (@calebaq)
 * [3 years ago](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/#post-16790657)
 * Ah gotcha! That makes sense.
 * We do have a programmatic condition here that adds an `s` to the array when a
   search term is passed. I just didn’t include it here since I was testing just
   getting the conditionals to work out, otherwise I’d definitely just run through
   it WP_Query to keep it easy (since it worked just fine).
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Relevanssi - A Better Search] No results when using complex tax queries](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/)
 *  Thread Starter [calebaq](https://wordpress.org/support/users/calebaq/)
 * (@calebaq)
 * [3 years ago](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/#post-16790018)
 * Additional context – Results that are tagged with the first condition of having
   the market `germany` applied does return results. It’s only results for the second
   criteria that are not returning items.
 * Looking through the MySQL output, the term IDs do match up at least. I’m not 
   sure about that ID FROM wp_posts WHERE 1=1 condition though.
 *   Forum: [Plugins](https://wordpress.org/support/forum/plugins-and-hacks/)
    In
   reply to: [[Relevanssi - A Better Search] No results when using complex tax queries](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/)
 *  Thread Starter [calebaq](https://wordpress.org/support/users/calebaq/)
 * (@calebaq)
 * [3 years ago](https://wordpress.org/support/topic/no-results-when-using-complex-tax-queries/#post-16790005)
 * Sure! It does work just fine with a simple tax queries. It only started struggling
   for me when I needed to work with this one specific AND case relationship.
 * Here is the output of that filter:
 *     ```wp-block-code
       SELECT DISTINCT(relevanssi.doc), 1 AS term, 1 AS term_reverse,
       		1 AS content, 1 AS title, 1 AS comment, 1 AS tag, 1 AS link, 1 AS
       		author, 1 AS category, 1 AS excerpt, 1 AS taxonomy, 1 AS customfield,
       		1 AS mysqlcolumn, 1 AS taxonomy_detail, 1 AS customfield_detail, 1 AS
       		mysqlcolumn_detail, type, item, 1 AS tf
       		FROM wp_relevanssi AS relevanssi 
       		WHERE relevanssi.term = relevanssi.term  AND ( relevanssi.doc IN (
       			SELECT DISTINCT(tr.object_id)
       			FROM wp_term_relationships AS tr
       			WHERE tr.term_taxonomy_id IN (17)
       		) OR relevanssi.doc IN (
       				SELECT ID FROM wp_posts WHERE 1=1
       				AND (
       					SELECT COUNT(1)
       					FROM wp_term_relationships AS tr
       					WHERE tr.term_taxonomy_id IN (51,22)
       					AND tr.object_id = wp_posts.ID ) = 2
       				) OR relevanssi.doc IN (
       				SELECT ID FROM wp_posts WHERE 1=1
       				AND (
       					SELECT COUNT(1)
       					FROM wp_term_relationships AS tr
       					WHERE tr.term_taxonomy_id IN (12,11)
       					AND tr.object_id = wp_posts.ID ) = 2
       				)) AND ( relevanssi.doc IN (
       			SELECT DISTINCT(tr.object_id)
       			FROM wp_term_relationships AS tr
       			WHERE tr.term_taxonomy_id IN (17)
       		) OR relevanssi.doc IN (
       				SELECT ID FROM wp_posts WHERE 1=1
       				AND (
       					SELECT COUNT(1)
       					FROM wp_term_relationships AS tr
       					WHERE tr.term_taxonomy_id IN (51,22)
       					AND tr.object_id = wp_posts.ID ) = 2
       				) OR relevanssi.doc IN (
       				SELECT ID FROM wp_posts WHERE 1=1
       				AND (
       					SELECT COUNT(1)
       					FROM wp_term_relationships AS tr
       					WHERE tr.term_taxonomy_id IN (12,11)
       					AND tr.object_id = wp_posts.ID ) = 2
       				)) AND (
       			relevanssi.doc IN (
       				SELECT DISTINCT(posts.ID) FROM wp_posts AS posts
       				WHERE posts.post_type IN ('job')
       			) 
       		) GROUP BY doc, item, type ORDER BY doc ASC LIMIT 500
       ```
   

Viewing 4 replies - 1 through 4 (of 4 total)