ElasticPress
ElasticPress copied to clipboard
Theme specific CPTs / Taxonomies not indexed when using --network-wide flag
Take the example of a custom taxonomy "review-type" being registered by theme code on blog_id 2 - since that site's theme is not loaded with the --network-wide flag, the taxonomy is never indexed into elasticsearch. By using the --url flag and doing site by site, you do get this data (since wp-cli sets up the environment as if you are running that site specifically when using --url)
Same thign for CPTs that are registered in site-specific themes - they do not get indexed.
The following command gets around this for now by indexing each site individually.
#!/bin/bash
for url in $(wp site list --field=url)
do
echo "Indexing for $url..."
wp elasticpress index --url=$url
done
Ideas to actually solve this problem long term...
-
wp_remote_post()
to each site on the network from the main wp-cli process - return a list of public CPTs and Taxonomies in the POST, and then continue to index those as normal from the main process (remote post only for getting the list of CPTs and Taxonomies avoids potential timeout issues trying to actually index on the POST request) - Could be an issue on some setups or where the url is not publicly accessible
@allan23 before I dig too deep on this have you made any progress?
@allan23 / @tlovett1 I want to bump this thread, for our next release fix?
I know I was thinking of the REST API as a possible solution.
Why not set a transient of custom post types / taxonomies?
Another alternative would be to have developers utilize the ep_indexable_post_types
filter.
Too difficult to fix. Use bash script
Will prep a MR to actually resolve this internally at least in WP-CLI through \WP_CLI\Process->run() In this way we can invoke a command for each site and ensure it runs with proper environment set up