You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your enhancement related to a problem? Please describe.
The Instant Results feature requires a search template be saved to ElasticPress.io to help power the API. This template is saved when the feature is activated, on sync, or on a change to the weighting settings. It is deleted when the feature is deactivated.
There is currently no direct way to manually save and delete this template outside of the UI except for running a sync. Since these specific UIs are unavailable per-site when in network mode the only way to save this template is to run a sync. For simplicity and clarity a specific command for saving the template would be preferable to the sync command.
Describe the solution you'd like
Add WP CLI commands for getting, saving, and deleting the search template from ElasticPress.io, eg.
wp elasticpress get-search-template
wp elasticpress put-search-template
wp elasticpress delete-search-template
Methods for each of these already exist on the InstantResults feature class, they just need to be added as commands.
new InstantResults\InstantResults()->epio_get_search_template()
new InstantResults\InstantResults()->epio_save_search_template()
new InstantResults\InstantResults()->epio_delete_search_template()
The text was updated successfully, but these errors were encountered:
Should we have a command also for getting the "local" version of the template? epio_get_search_template() gets the version that's hosted in EPIO. Not sure if it would be handy for let's say, compare what you generate locally vs saved version.
epio_save_search_template() and epio_delete_search_template() returns void, so the WP CLI command would only run that method, but it doesn't know if saving/deleting the template was successful or not. I think this is also an improvement we could make in general. Right now it seems there's no way to know if saving the search template was successful or not. Having it returning the response can help with displaying a notice in WP Admin as well
Another thing I think we can address is better describe the methods, for example
/**
* Save the search template to ElasticPress.io.
*
* @return void
*/
public function epio_save_search_template() {
$endpoint = $this->get_template_endpoint();
$template = $this->get_search_template();
Elasticsearch::factory()->remote_request(
$endpoint,
[
'blocking' => false,
'body' => $template,
'method' => 'PUT',
]
);
/**
* Fires after the request is sent the search template API endpoint.
*
* @since 4.0.0
* @hook ep_instant_results_template_saved
* @param {string} $template The search template (JSON).
* @param {string} $index Index name.
*/
do_action( 'ep_instant_results_template_saved', $template, $this->index );
}
This method doc and name imply the template is saved to EPIO and while that is true it can be confusing for people who are not using EPIO. This method seems to achieve the same for both
Is your enhancement related to a problem? Please describe.
The Instant Results feature requires a search template be saved to ElasticPress.io to help power the API. This template is saved when the feature is activated, on sync, or on a change to the weighting settings. It is deleted when the feature is deactivated.
There is currently no direct way to manually save and delete this template outside of the UI except for running a sync. Since these specific UIs are unavailable per-site when in network mode the only way to save this template is to run a sync. For simplicity and clarity a specific command for saving the template would be preferable to the sync command.
Describe the solution you'd like
Add WP CLI commands for getting, saving, and deleting the search template from ElasticPress.io, eg.
wp elasticpress get-search-template
wp elasticpress put-search-template
wp elasticpress delete-search-template
Methods for each of these already exist on the InstantResults feature class, they just need to be added as commands.
new InstantResults\InstantResults()->epio_get_search_template()
new InstantResults\InstantResults()->epio_save_search_template()
new InstantResults\InstantResults()->epio_delete_search_template()
The text was updated successfully, but these errors were encountered: