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

Add solutions for failed queries due to field type issues. #3165

Merged
merged 2 commits into from
Nov 29, 2022
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Put reused message into variable.
  • Loading branch information
JakePT committed Nov 29, 2022
commit f5da690f3d5ad50db34cbc7ec0a7ccfff9dcacf6
30 changes: 10 additions & 20 deletions includes/classes/StatusReport/FailedQueries.php
Original file line number Diff line number Diff line change
Expand Up @@ -169,12 +169,14 @@ protected function analyze_log( $log ) {
* @return string
*/
protected function maybe_suggest_solution_for_es( $error ) {
$sync_url = Utils\get_sync_url();

if ( preg_match( '/no such index \[(.*?)\]/', $error, $matches ) ) {
return sprintf(
/* translators: 1. Index name; 2. Sync Page URL */
__( 'It seems the %1$s index is missing. <a href="%2$s">Delete all data and sync</a> to fix the issue.', 'elasticpress' ),
'<code>' . $matches[1] . '</code>',
Utils\get_sync_url()
$sync_url
);
}

Expand All @@ -183,35 +185,23 @@ protected function maybe_suggest_solution_for_es( $error ) {
/* translators: 1. Index name; 2. Sync Page URL */
__( 'The field %1$s was not found. Make sure it is added to the list of indexed fields and run <a href="%2$s">a new sync</a> to fix the issue.', 'elasticpress' ),
'<code>' . $matches[1] . '</code>',
Utils\get_sync_url()
$sync_url
);
}

/* translators: 1. Field name; 2. Sync Page URL */
$field_type_solution = __( 'It seems you saved a post without doing a full sync first because <code>%1$s</code> is missing the correct mapping type. <a href="%2$s">Delete all data and sync</a> to fix the issue.', 'elasticpress' );

if ( preg_match( '/Fielddata is disabled on text fields by default. Set fielddata=true on \[(.*?)\]/', $error, $matches ) ) {
return sprintf(
/* translators: 1. Field name; 2. Sync Page URL */
__( 'It seems you saved a post without doing a full sync first because %1$s is missing the correct mapping type. <a href="%2$s">Delete all data and sync</a> to fix the issue.', 'elasticpress' ),
'<code>' . $matches[1] . '</code>',
Utils\get_sync_url()
);
return sprintf( $field_type_solution, $matches[1], $sync_url );
}

if ( preg_match( '/field \[(.*?)\] is of type \[(.*?)\], but only numeric types are supported./', $error, $matches ) ) {
return sprintf(
/* translators: 1. Field name; 2. Sync Page URL */
__( 'It seems you saved a post without doing a full sync first because %1$s is missing the correct mapping type. <a href="%2$s">Delete all data and sync</a> to fix the issue.', 'elasticpress' ),
'<code>' . $matches[1] . '</code>',
Utils\get_sync_url()
);
return sprintf( $field_type_solution, $matches[1], $sync_url );
}

if ( preg_match( '/Alternatively, set fielddata=true on \[(.*?)\] in order to load field data by uninverting the inverted index./', $error, $matches ) ) {
return sprintf(
/* translators: 1. Field name; 2. Sync Page URL */
__( 'It seems you saved a post without doing a full sync first because %1$s is missing the correct mapping type. <a href="%2$s">Delete all data and sync</a> to fix the issue.', 'elasticpress' ),
'<code>' . $matches[1] . '</code>',
Utils\get_sync_url()
);
return sprintf( $field_type_solution, $matches[1], $sync_url );
}

if ( preg_match( '/Limit of total fields \[(.*?)\] in index \[(.*?)\] has been exceeded/', $error, $matches ) ) {
Expand Down