Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Combining elastic search with tax_query #3908

Open
1 task done
jacobmasters opened this issue May 10, 2024 · 3 comments
Open
1 task done

Combining elastic search with tax_query #3908

jacobmasters opened this issue May 10, 2024 · 3 comments

Comments

@jacobmasters
Copy link

jacobmasters commented May 10, 2024

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

  • I agree to follow this project's Code of Conduct
@jacobmasters jacobmasters changed the title Running outside of the WordPress directory, semi-headless Combining elastic search with tax_query May 13, 2024
@jacobmasters
Copy link
Author

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?

@felipeelia
Copy link
Member

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.

Copy link

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 github-actions bot added the stale label May 31, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants