ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Theme specific CPTs / Taxonomies not indexed when using --network-wide flag

Open cmmarslender opened this issue 9 years ago • 5 comments

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

cmmarslender avatar Aug 18 '15 00:08 cmmarslender

@allan23 before I dig too deep on this have you made any progress?

ChrisWiegman avatar Jan 28 '16 15:01 ChrisWiegman

@allan23 / @tlovett1 I want to bump this thread, for our next release fix?

ivankristianto avatar May 29 '17 05:05 ivankristianto

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.

allan23 avatar Jun 26 '17 23:06 allan23

Too difficult to fix. Use bash script

tlovett1 avatar Jun 27 '17 16:06 tlovett1

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

tott avatar Jun 18 '19 19:06 tott