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

Mapping failed because of max_shingle_size .. I have changed settings but not working as its creating new index all time and applying settings-- version 4.2.0 #2806

Closed
balajidamodare opened this issue May 30, 2022 · 5 comments
Labels

Comments

@balajidamodare
Copy link

balajidamodare commented May 30, 2022

command: wp elasticpress put-mapping

Describe your question

Error:
Query Response Code: HTTP 400
Query Result:

{
    "error": {
        "root_cause": [
            {
                "type": "illegal_argument_exception",
                "reason": "In Shingle TokenFilter the difference between max_shingle_size and min_shingle_size (and +1 if outputting unigrams) must be less than or equal to: [3] but was [4]. This limit can be set by changing the [index.max_shingle_diff] index level setting."
            }
        ],
        "type": "illegal_argument_exception",
        "reason": "In Shingle TokenFilter the difference between max_shingle_size and min_shingle_size (and +1 if outputting unigrams) must be less than or equal to: [3] but was [4]. This limit can be set by changing the [index.max_shingle_diff] index level setting."
    },
    "status": 400
}

any plugin settings will help to resolve this?

I am using already one filter to resolve this.
// to resolve max_shingle_diff issue default allowed 5
apply_filters( 'ep_max_shingle_diff', 10 );

@balajidamodare balajidamodare changed the title Mapping failed because of max_shingle_size changed settings but now working as its creating new index all time Mapping failed because of max_shingle_size changed settings but now working as its creating new index all time -- version 4.1.0 May 30, 2022
@balajidamodare balajidamodare changed the title Mapping failed because of max_shingle_size changed settings but now working as its creating new index all time -- version 4.1.0 Mapping failed because of max_shingle_size .. I have changed settings but now working as its creating new index all time and applying settings-- version 4.1.0 May 30, 2022
@balajidamodare balajidamodare changed the title Mapping failed because of max_shingle_size .. I have changed settings but now working as its creating new index all time and applying settings-- version 4.1.0 Mapping failed because of max_shingle_size .. I have changed settings but not working as its creating new index all time and applying settings-- version 4.1.0 May 30, 2022
@balajidamodare balajidamodare changed the title Mapping failed because of max_shingle_size .. I have changed settings but not working as its creating new index all time and applying settings-- version 4.1.0 Mapping failed because of max_shingle_size .. I have changed settings but not working as its creating new index all time and applying settings-- version 4.2.0 May 30, 2022
@felipeelia
Copy link
Member

Hi @balajidamodare,

Thanks for opening the issue. Before anything else, I think we need to align our expectations here :) Right now, you have the same problem reported in 3 different places, and that does not help anyone: it won't make us get to your question any faster and will not help to keep the repository organized for others with the same problem. That said, it is enough to report your problem only once, we will eventually get to it. I really hope you understand.

Can you please run the following command and let us know the results?

wp eval 'print_r(\ElasticPress\Indexables::factory()->get( "post" )->generate_mapping());'

You will also need to replace "post" with "user" to check the mapping sent for that feature.

@balajidamodare
Copy link
Author

balajidamodare commented May 31, 2022

@felipeelia Thank you for responding. I was a little bit confused is this the question or bug that's the reason I have reported separately and in the comment as well.
here is the result for post
command: wp eval 'print_r(\ElasticPress\Indexables::factory()->get( "post" )->generate_mapping());'
Result: `Array
(
[settings] => Array
(
[index.number_of_shards] => 5
[index.number_of_replicas] => 1
[analysis] => Array
(
[analyzer] => Array
(
[default] => Array
(
[tokenizer] => standard
[filter] => Array
(
[0] => standard
[1] => ewp_word_delimiter
[2] => lowercase
[3] => stop
[4] => ewp_snowball
)

                                [language] => english
                            )

                        [shingle_analyzer] => Array
                            (
                                [type] => custom
                                [tokenizer] => standard
                                [filter] => Array
                                    (
                                        [0] => lowercase
                                        [1] => shingle_filter
                                    )

                            )

                        [ewp_lowercase] => Array
                            (
                                [type] => custom
                                [tokenizer] => keyword
                                [filter] => Array
                                    (
                                        [0] => lowercase
                                    )

                            )

                    )

                [filter] => Array
                    (
                        [shingle_filter] => Array
                            (
                                [type] => shingle
                                [min_shingle_size] => 2
                                [max_shingle_size] => 5
                            )

                        [ewp_word_delimiter] => Array
                            (
                                [type] => word_delimiter
                                [preserve_original] => 1
                            )

                        [ewp_snowball] => Array
                            (
                                [type] => snowball
                                [language] => english
                            )

                        [edge_ngram] => Array
                            (
                                [side] => front
                                [max_gram] => 10
                                [min_gram] => 3
                                [type] => edgeNGram
                            )

                    )

            )

    )

[mappings] => Array
    (
        [post] => Array
            (
                [_meta] => Array
                    (
                        [mapping_version] => pre-5-0.php
                    )

                [date_detection] => 
                [dynamic_templates] => Array
                    (
                        [0] => Array
                            (
                                [template_meta] => Array
                                    (
                                        [path_match] => post_meta.*
                                        [mapping] => Array
                                            (
                                                [type] => multi_field
                                                [path] => full
                                                [fields] => Array
                                                    (
                                                        [{name}] => Array
                                                            (
                                                                [type] => string
                                                                [index] => analyzed
                                                            )

                                                        [raw] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                                [include_in_all] => 
                                                            )

                                                    )

                                            )

                                    )

                            )

                        [1] => Array
                            (
                                [template_meta_types] => Array
                                    (
                                        [path_match] => meta.*
                                        [mapping] => Array
                                            (
                                                [type] => object
                                                [path] => full
                                                [properties] => Array
                                                    (
                                                        [value] => Array
                                                            (
                                                                [type] => string
                                                                [fields] => Array
                                                                    (
                                                                        [sortable] => Array
                                                                            (
                                                                                [type] => string
                                                                                [analyzer] => ewp_lowercase
                                                                                [include_in_all] => 
                                                                            )

                                                                        [raw] => Array
                                                                            (
                                                                                [type] => string
                                                                                [index] => not_analyzed
                                                                                [include_in_all] => 
                                                                            )

                                                                    )

                                                            )

                                                        [raw] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                                [include_in_all] => 
                                                            )

                                                        [long] => Array
                                                            (
                                                                [type] => long
                                                                [index] => not_analyzed
                                                            )

                                                        [double] => Array
                                                            (
                                                                [type] => double
                                                                [index] => not_analyzed
                                                            )

                                                        [boolean] => Array
                                                            (
                                                                [type] => boolean
                                                                [index] => not_analyzed
                                                            )

                                                        [date] => Array
                                                            (
                                                                [type] => date
                                                                [format] => yyyy-MM-dd
                                                                [index] => not_analyzed
                                                            )

                                                        [datetime] => Array
                                                            (
                                                                [type] => date
                                                                [format] => yyyy-MM-dd HH:mm:ss
                                                                [index] => not_analyzed
                                                            )

                                                        [time] => Array
                                                            (
                                                                [type] => date
                                                                [format] => HH:mm:ss
                                                                [index] => not_analyzed
                                                            )

                                                    )

                                            )

                                    )

                            )

                        [2] => Array
                            (
                                [template_terms] => Array
                                    (
                                        [path_match] => terms.*
                                        [mapping] => Array
                                            (
                                                [type] => object
                                                [path] => full
                                                [properties] => Array
                                                    (
                                                        [name] => Array
                                                            (
                                                                [type] => string
                                                                [fields] => Array
                                                                    (
                                                                        [raw] => Array
                                                                            (
                                                                                [type] => string
                                                                                [index] => not_analyzed
                                                                            )

                                                                        [sortable] => Array
                                                                            (
                                                                                [type] => string
                                                                                [analyzer] => ewp_lowercase
                                                                            )

                                                                    )

                                                            )

                                                        [term_id] => Array
                                                            (
                                                                [type] => long
                                                            )

                                                        [term_taxonomy_id] => Array
                                                            (
                                                                [type] => long
                                                            )

                                                        [parent] => Array
                                                            (
                                                                [type] => long
                                                            )

                                                        [slug] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                            )

                                                        [facet] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                            )

                                                        [term_order] => Array
                                                            (
                                                                [type] => long
                                                            )

                                                    )

                                            )

                                    )

                            )

                        [3] => Array
                            (
                                [term_suggest] => Array
                                    (
                                        [path_match] => term_suggest_*
                                        [mapping] => Array
                                            (
                                                [type] => completion
                                                [analyzer] => default
                                            )

                                    )

                            )

                    )

                [_all] => Array
                    (
                        [analyzer] => simple
                    )

                [properties] => Array
                    (
                        [post_id] => Array
                            (
                                [type] => long
                                [index] => not_analyzed
                                [include_in_all] => 
                            )

                        [ID] => Array
                            (
                                [type] => long
                                [index] => not_analyzed
                                [include_in_all] => 
                            )

                        [post_author] => Array
                            (
                                [type] => object
                                [properties] => Array
                                    (
                                        [display_name] => Array
                                            (
                                                [type] => string
                                                [fields] => Array
                                                    (
                                                        [raw] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                            )

                                                        [sortable] => Array
                                                            (
                                                                [type] => string
                                                                [analyzer] => ewp_lowercase
                                                            )

                                                    )

                                            )

                                        [login] => Array
                                            (
                                                [type] => string
                                                [fields] => Array
                                                    (
                                                        [raw] => Array
                                                            (
                                                                [type] => string
                                                                [index] => not_analyzed
                                                            )

                                                        [sortable] => Array
                                                            (
                                                                [type] => string
                                                                [analyzer] => ewp_lowercase
                                                            )

                                                    )

                                            )

                                        [id] => Array
                                            (
                                                [type] => long
                                                [index] => not_analyzed
                                            )

                                        [raw] => Array
                                            (
                                                [type] => string
                                                [index] => not_analyzed
                                                [include_in_all] => 
                                            )

                                    )

                            )

                        [post_date] => Array
                            (
                                [type] => date
                                [format] => YYYY-MM-dd HH:mm:ss
                                [include_in_all] => 
                            )

                        [post_date_gmt] => Array
                            (
                                [type] => date
                                [format] => YYYY-MM-dd HH:mm:ss
                                [include_in_all] => 
                            )

                        [post_title] => Array
                            (
                                [type] => multi_field
                                [fields] => Array
                                    (
                                        [post_title] => Array
                                            (
                                                [type] => string
                                                [analyzer] => standard
                                                [store] => yes
                                            )

                                        [raw] => Array
                                            (
                                                [type] => string
                                                [index] => not_analyzed
                                                [include_in_all] => 
                                            )

                                        [sortable] => Array
                                            (
                                                [type] => string
                                                [analyzer] => ewp_lowercase
                                                [include_in_all] => 
                                            )

                                    )

                            )

                        [post_excerpt] => Array
                            (
                                [type] => string
                            )

                        [post_content] => Array
                            (
                                [type] => string
                                [analyzer] => default
                            )

                        [post_status] => Array
                            (
                                [type] => string
                                [index] => not_analyzed
                            )

                        [post_name] => Array
                            (
                                [type] => multi_field
                                [fields] => Array
                                    (
                                        [post_name] => Array
                                            (
                                                [type] => string
                                            )

                                        [raw] => Array
                                            (
                                                [type] => string
                                                [index] => not_analyzed
                                                [include_in_all] => 
                                            )

                                    )

                            )

                        [post_modified] => Array
                            (
                                [type] => date
                                [format] => YYYY-MM-dd HH:mm:ss
                                [include_in_all] => 
                            )

                        [post_modified_gmt] => Array
                            (
                                [type] => date
                                [format] => YYYY-MM-dd HH:mm:ss
                                [include_in_all] => 
                            )

                        [post_parent] => Array
                            (
                                [type] => long
                                [index] => not_analyzed
                                [include_in_all] => 
                            )

                        [post_type] => Array
                            (
                                [type] => multi_field
                                [fields] => Array
                                    (
                                        [post_type] => Array
                                            (
                                                [type] => string
                                            )

                                        [raw] => Array
                                            (
                                                [type] => string
                                                [index] => not_analyzed
                                                [include_in_all] => 
                                            )

                                    )

                            )

                        [post_mime_type] => Array
                            (
                                [type] => string
                                [index] => not_analyzed
                                [include_in_all] => 
                            )

                        [permalink] => Array
                            (
                                [type] => string
                            )

                        [guid] => Array
                            (
                                [type] => string
                                [index] => not_analyzed
                            )

                        [terms] => Array
                            (
                                [type] => object
                            )

                        [post_meta] => Array
                            (
                                [type] => object
                            )

                        [meta] => Array
                            (
                                [type] => object
                            )

                        [date_terms] => Array
                            (
                                [type] => object
                                [properties] => Array
                                    (
                                        [year] => Array
                                            (
                                                [type] => integer
                                            )

                                        [month] => Array
                                            (
                                                [type] => integer
                                            )

                                        [m] => Array
                                            (
                                                [type] => integer
                                            )

                                        [week] => Array
                                            (
                                                [type] => integer
                                            )

                                        [day] => Array
                                            (
                                                [type] => integer
                                            )

                                        [dayofweek] => Array
                                            (
                                                [type] => integer
                                            )

                                        [dayofweek_iso] => Array
                                            (
                                                [type] => integer
                                            )

                                        [dayofyear] => Array
                                            (
                                                [type] => integer
                                            )

                                        [hour] => Array
                                            (
                                                [type] => integer
                                            )

                                        [minute] => Array
                                            (
                                                [type] => integer
                                            )

                                        [second] => Array
                                            (
                                                [type] => integer
                                            )

                                    )

                            )

                        [thumbnail] => Array
                            (
                                [type] => object
                                [properties] => Array
                                    (
                                        [ID] => Array
                                            (
                                                [type] => long
                                            )

                                        [src] => Array
                                            (
                                                [type] => text
                                            )

                                        [width] => Array
                                            (
                                                [type] => integer
                                            )

                                        [height] => Array
                                            (
                                                [type] => integer
                                            )

                                        [alt] => Array
                                            (
                                                [type] => text
                                            )

                                    )

                            )

                    )

            )

    )

)`

and for the user getting error
Command: wp eval 'print_r(\ElasticPress\Indexables::factory()->get( "user" )->generate_mapping());'
Result :
PHP Fatal error: Uncaught Error: Call to a member function generate_mapping() on bool in phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37) : eval()'d code:1 Stack trace: #0 phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37): eval() #1 [internal function]: Eval_Command->__invoke() #2 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(98): call_user_func() #3 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}() #4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(451): call_user_func() #5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(371): WP_CLI\Dispatcher\Subcommand->invoke() #6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(394): WP_CLI\Runner->run_command() #7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(87): WP_CLI\Runner->run_command_and_exit() #8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Ru in phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37) : eval()'d code on line 1 Fatal error: Uncaught Error: Call to a member function generate_mapping() on bool in phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37) : eval()'d code:1 Stack trace: #0 phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37): eval() #1 [internal function]: Eval_Command->__invoke() #2 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/CommandFactory.php(98): call_user_func() #3 [internal function]: WP_CLI\Dispatcher\CommandFactory::WP_CLI\Dispatcher\{closure}() #4 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Dispatcher/Subcommand.php(451): call_user_func() #5 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(371): WP_CLI\Dispatcher\Subcommand->invoke() #6 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(394): WP_CLI\Runner->run_command() #7 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Runner.php(87): WP_CLI\Runner->run_command_and_exit() #8 phar:///usr/local/bin/wp/vendor/wp-cli/wp-cli/php/WP_CLI/Ru in phar:///usr/local/bin/wp/vendor/wp-cli/eval-command/src/Eval_Command.php(37) : eval()'d code on line 1 Error: There has been a critical error on this website.Learn more about troubleshooting WordPress. There has been a critical error on this website.

@balajidamodare
Copy link
Author

HI @felipeelia
any solution to this issue?

@felipeelia
Copy link
Member

@balajidamodare, I guess I was not clear enough in my last reply. Please, do NOT try to bump your questions. As you are using OpenSearch and that is not something we officially support, you will face errors that are not necessarily bugs but things that need to be worked around.
In addition to that, it is worth saying that the scope of our GitHub issues is to file and organize bug reports and enhancements related to the plugin. It is NOT to provide hands-on support. As I said before, it is enough to report your problem only once, we will eventually get to it. I really hope you understand.

With all that said, I gave OpenSearch a try and an adjustment is needed in the version understood by ElasticPress. As OpenSearch will report its version as 1.x or 2.x, ElasticPress will see that as an older version of Elasticsearch and use wrong mappings. To circumvent that, this snippet can be used:

add_filter(
	'ep_elasticsearch_version',
	function() {
		return '7.10';
	}
);

@balajidamodare
Copy link
Author

@felipeelia
adding filter worked for me thanks a lot. and sorry for adding too many comments and questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants