弹性搜索内部结果窗口太大

时间:2018-09-17 12:52:13

标签: elasticsearch

我正在使用节点弹性客户端进行弹性搜索,这就是我的模式

{
        "settings": {
            "number_of_shards": 1,
            "number_of_replicas": 0,
            "analysis": {
                "filter": {
                    "my_ascii_folding": {
                        "type": "asciifolding",
                        "preserve_original": "true"
                    }
                },
                "analyzer": {
                    "include_special_character_gram": {
                        "type": "custom",
                        "filter": [
                            "lowercase",
                            "my_ascii_folding"
                        ],
                        "tokenizer": "ngram_tokenizer"
                    }
                },
                "tokenizer": {
                    "ngram_tokenizer": {
                        "type": "ngram",
                        "min_gram": 1,
                        "max_gram": 200,
                        "token_chars": [
                            "letter",
                            "digit",
                            "punctuation",
                            "symbol",
                            "whitespace"
                        ]
                    }
                }
            }
        },
        "mappings": {
            "product": {
                "properties": {
                    "name": {
                        "type": "text", 
                        "index": true, 
                        "fielddata": true,
                        "analyzer": "include_special_character_gram",
                        "search_analyzer": "keyword",
                    }, 
                    "id": {"type": "keyword", "index": true},
                    "slug": {"type": "keyword", "index": true},
                    "userid": {"type": "keyword", "index": true},
                    "createdAt":{"type": "date"},
                    "products":{
                        "type": "nested",
                        "properties": {
                            "id": {"type": "keyword", "index": true},
                            "name": {
                                "type": "text", 
                                "index": true, 
                                "fielddata": true,
                                "analyzer": "include_special_character_gram",
                                "search_analyzer": "keyword",
                            },
                            "categories":{
                                "type": "nested",
                                "properties": {
                                    "id": {"type": "keyword", "index": true},
                                    "name": {
                                        "type": "text", 
                                        "index": true,
                                        "fielddata": true,
                                        "analyzer": "include_special_character_gram",
                                        "search_analyzer": "keyword",
                                    },
                                    "short_name": {"type": "text"},
                                }
                            }
                        }
                    },
                }
            } 
        }
    }

这是我执行的查询

var esQuery = {
        "query": {
            "bool":{
                "must":[
                    {"term": {"userid": "test"}},
                    {"simple_query_string" : {"query": "test", "fields": ["name"], "default_operator": "AND", "flags" : "PREFIX"}}
                ]
            }
        }
    };
    esQuery.query.bool.filter = [];
     {"nested": {
                "path": "products",
                "query": {
                    "bool": {
                        "should":[
                            {"nested": {
                                "path": "products.categories",
                                "query": {"term" : {"products.categories.name": "test"}}
                            }},
                            {"match" : {"products.name": "test"}}
                        ]
                    }
                },
                "inner_hits": {
                    "size": 50,
                    "from": 100,
                    "sort": {"products.name": "asc"},
                    "_source": {
                        "includes": ["products._id", "products.name", "products.link", "products.image","products.source_type"]
                    }
                }
            }}
        esClient.search({index: 'organizer', type: 'product', body: esQuery}, function(error, response){});

执行此操作时出现错误

"{"error":{"root_cause":[{"type":"illegal_argument_exception","reason":"Inner result window is too large, the inner hit definition's [null]'s from + size must be less than or equal to: [100] but was [150]. This limit can be set by changing the [index.max_inner_result_window] index level setting."}],"type":"search_phase_execution_exception","reason":"all shards failed","phase":"query","grouped":true,"failed_shards":[{"shard":0,"index":"organizer","node":"rUtntV4bQAG58ckVd3TRQg","reason":{"type":"illegal_argument_exception","reason":"Inner result window is too large, the inner hit definition's [null]'s from + size must be less than or equal to: [100] but was [150]. This limit can be set by changing the [index.max_inner_result_window] index level setting."}}],"caused_by":{"type":"illegal_argument_exception","reason":"Inner result window is too large, the inner hit definition's [null]'s from + size must be less than or equal to: [100] but was [150]. This limit can be set by changing the [index.max_inner_result_window] index level setting.","caused_by":{"type":"illegal_argument_exception","reason":"Inner result window is too large, the inner hit definition's [null]'s from + size must be less than or equal to: [100] but was [150]. This limit can be set by changing the [index.max_inner_result_window] index level setting."}}},"status":400}"

当我研究此错误时,我对大型分页技术有了一些了解。但这对我不起作用,因为该分页仅在根级别应用。我需要在内部数组级别使用大深度分页。

有人可以帮助我解决这个问题吗?

谢谢。

0 个答案:

没有答案