ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Combining elastic search with tax_query

Open jacobmasters opened this issue 1 year ago • 1 comments

Is your enhancement related to a problem? Please describe.

I've a simple external page which just includes the wp-config file and disables all themes/most plugins to just run a simple get_posts search:

<? define('WP_USE_THEMES', false); define('plugins-searchonly',true); require("../wp-config.php"); remove_filter('pre_get_posts', 'pre_get_filter'); $args = array('ep_integrate' => true,'posts_per_page' => -1,'post_type' => 'attachment','post_status' => 'any'); $args = array_merge( $args, array('s' => $_GET['search'])); $taxquery = array('tax_query' => array( array('taxonomy' => 'image-association','field' => 'slug', 'terms' => array('folio')))); $args = array_merge($args,$taxquery); $folios = get_posts($args) ; ?>

Currently wp-admin searches to attachments use Elasticsearch, so the index is in place, but using the stripped back code above does not and returns 0, does any global variable or wordpress element need including for it to work in this way?

Designs

No response

Describe alternatives you've considered

No response

Code of Conduct

  • [X] I agree to follow this project's Code of Conduct

jacobmasters avatar May 10 '24 18:05 jacobmasters

Started this as a headless issue, but in further testing its actually the tax_query addition to the search query that's throwing this out and resulting 0 results, is there a way to combine the two or do i need to filter after search?

jacobmasters avatar May 13 '24 09:05 jacobmasters

If you are sure ElasticPress is being loaded, that code should work, @jacobmasters. Is that image-association taxonomy indexable? If not, you may need to use the ep_sync_taxonomies filter to add it to the list.

felipeelia avatar May 27 '24 13:05 felipeelia

It has been 3 days since more information was requested from you in this issue and we have not heard back. This issue is now marked as stale and will be closed in 3 days, but if you have more information to add then please comment and the issue will stay open.

github-actions[bot] avatar May 31 '24 01:05 github-actions[bot]

This issue has been automatically closed because there has been no response to our request for more information in the past 3 days. With only the information that is currently available, we are unable to take further action on this ticket. Please reach out if you have found or find the answer we need so that we can investigate further. When the information is ready, you can re-open this ticket to share it with us.

github-actions[bot] avatar Jun 03 '24 01:06 github-actions[bot]