elasticsearch,mustache,collate,Json,elasticsearch,Mustache,Collate" /> elasticsearch,mustache,collate,Json,elasticsearch,Mustache,Collate" />

Json 建议阶段使用内联排序查询时出现Elasticsearch I/O异常

Json 建议阶段使用内联排序查询时出现Elasticsearch I/O异常,json,elasticsearch,mustache,collate,Json,elasticsearch,Mustache,Collate,我在ES 5.2中的短语建议查询中有一个collate查询。为了做到这一点,我的collate查询是一个内联胡须模板。但是,我得到一个I/O异常错误,告诉我在使用toJson mustache标记向查询传递筛选器对象时,出现了一个意外的“}”字符 令人惊讶的是,当我使用搜索/模板端点时,我的查询模板似乎没有问题。通过这种方式我没有任何错误 我的问题是: { "index": "arrets27", "type": "arret", "body": { "

我在ES 5.2中的短语建议查询中有一个collate查询。为了做到这一点,我的collate查询是一个内联胡须模板。但是,我得到一个I/O异常错误,告诉我在使用toJson mustache标记向查询传递筛选器对象时,出现了一个意外的“}”字符

令人惊讶的是,当我使用搜索/模板端点时,我的查询模板似乎没有问题。通过这种方式我没有任何错误

我的问题是:

{
    "index": "arrets27",
    "type": "arret",
    "body": {

        "suggest": {
            "text": "secs, Bovero,",
            "simple_phrase": {
                "phrase": {
                    "field": "contenu_html.trigram",
                    "size": 1,
                    "gram_size": 3,
                    "max_errors": 2,
                    "confidence": 2.5,
                    "direct_generator": [{
                        "field": "contenu_html.trigram",
                        "suggest_mode": "always"
                    }, {
                        "field": "contenu_html.reverse",
                        "suggest_mode": "always",
                        "pre_filter": "reverse",
                        "post_filter": "reverse"
                    }, {
                        "field": "contenu_html.nostem_with_accents",
                        "suggest_mode": "missing"
                    }],
                    "collate": {
                        "query": {
                            "params": {
                                "filters": [{
                                    "bool": {
                                        "should": [{
                                            "term": {
                                                "juridiction.raw": "CE"
                                            }
                                        }]
                                    }
                                }, {
                                    "bool": {
                                        "should": [{
                                            "term": {
                                                "search_access.raw": "ALL"
                                            }
                                        }, {
                                            "term": {
                                                "search_access.raw": "FREE_TRIAL"
                                            }
                                        }, {
                                            "term": {
                                                "search_access.raw": "RESTRICTED"
                                            }
                                        }]
                                    }
                                }]
                            },
                            "inline": "{\"bool\":{\"must\":[{\"multi_match\":{\"query\":\"{{suggestion}}\",\"analyzer\":\"query_analyzer\",\"type\":\"cross_fields\",\"fields\":[\"doc_id^2\",\"search_title^0.1\",\"formation^2\",\"form_dec_att^1\",\"president^1\",\"avocat_gl^1\",\"avocats^1\",\"rapporteur^1\",\"commissaire_gvt^1\",\"citation_jp^0.05\",\"keywords^2\",\"liens^2\",\"numero^4\",\"numero_affaire^4\",\"other_numbers^4\",\"solution^2\",\"nature^2\",\"ville^2\",\"siege_appel^2\",\"juri_prem^2\",\"lieu_prem^2\",\"ecli^2\",\"reference_url^2\",\"wikipedia^100\",\"ancien_id^2\",\"type_rec^2\",\"nor^2\",\"nature_qualifiee^2\",\"loi_def^2\",\"titre_jo^2\",\"loi_def_nor^2\",\"loi_def_num^2\",\"saisines^2\",\"observations^2\",\"publi_bull_ref^4\",\"ref_numeros_affaires^2\",\"organisations^2\",\"issue^2\",\"resolution_number^2\",\"doctype_branch^2\",\"legifrance_ref^2\",\"reference_citation^2\",\"inpi_ref^2\",\"inpi_partan^0.1\",\"inpi_marq^0.1\",\"inpi_prod^2\",\"inpi_ti^2\",\"inpi_obj^2\",\"inpi_cib^2\",\"inpi_ct^2\",\"demandeurs_names^0.1\",\"defendeurs_names^0.1\",\"comment_titles^1\",\"citation_titles^0.1\",\"contenu_html^1\",\"saisines_html^2\",\"observations_html^2\",\"sommaire_ana^2\",\"comment_contents^0.5\",\"citation_contents^0.05\"],\"operator\":\"and\"}}],\"filter\":{{#toJson}}filters{{/toJson}}}}"
                        },
                        "prune": true
                    }
                }
            }
        }
    }
}
这是我在ES中得到的错误日志:

[2017-05-30T12:34:32,697][DEBUG][o.e.a.s.TransportSearchAction] [index-dev1] [arrets27][4], node[rpBSnTFORcmlVzldTfAGYA], [P], s[STARTED], a[id=6P0qTS-CTxC-TYA5mQ041w]: Failed to execute [SearchRequest{searchType=QUERY_THEN_FETCH, indices=[arrets27], indicesOptions=IndicesOptions[id=38, ignore_unavailable=false, allow_no_indices=true, expand_wildcards_open=true, expand_wildcards_closed=false, allow_alisases_to_multiple_indices=true, forbid_closed_indices=true], types=[arret], routing='null', preference='null', requestCache=false, scroll=null, source={
  "suggest" : {
    "text" : "secs, Bovero,",
    "simple_phrase" : {
      "phrase" : {
        "field" : "contenu_html.trigram",
        "size" : 1,
        "real_word_error_likelihood" : 0.95,
        "confidence" : 2.5,
        "separator" : " ",
        "max_errors" : 2.0,
        "gram_size" : 3,
        "force_unigrams" : true,
        "token_limit" : 10,
        "direct_generator" : [
          {
            "field" : "contenu_html.trigram",
            "suggest_mode" : "always"
          },
          {
            "field" : "contenu_html.reverse",
            "pre_filter" : "reverse",
            "post_filter" : "reverse",
            "suggest_mode" : "always"
          },
          {
            "field" : "contenu_html.nostem_with_accents",
            "suggest_mode" : "missing"
          }
        ],
        "collate" : {
          "query" : {
            "inline" : "{\"bool\":{\"must\":[{\"multi_match\":{\"query\":\"{{suggestion}}\",\"analyzer\":\"query_analyzer\",\"type\":\"cross_fields\",\"fields\":[\"doc_id^2\",\"search_title^0.1\",\"formation^2\",\"form_dec_att^1\",\"president^1\",\"avocat_gl^1\",\"avocats^1\",\"rapporteur^1\",\"commissaire_gvt^1\",\"citation_jp^0.05\",\"keywords^2\",\"liens^2\",\"numero^4\",\"numero_affaire^4\",\"other_numbers^4\",\"solution^2\",\"nature^2\",\"ville^2\",\"siege_appel^2\",\"juri_prem^2\",\"lieu_prem^2\",\"ecli^2\",\"reference_url^2\",\"wikipedia^100\",\"ancien_id^2\",\"type_rec^2\",\"nor^2\",\"nature_qualifiee^2\",\"loi_def^2\",\"titre_jo^2\",\"loi_def_nor^2\",\"loi_def_num^2\",\"saisines^2\",\"observations^2\",\"publi_bull_ref^4\",\"ref_numeros_affaires^2\",\"organisations^2\",\"issue^2\",\"resolution_number^2\",\"doctype_branch^2\",\"legifrance_ref^2\",\"reference_citation^2\",\"inpi_ref^2\",\"inpi_partan^0.1\",\"inpi_marq^0.1\",\"inpi_prod^2\",\"inpi_ti^2\",\"inpi_obj^2\",\"inpi_cib^2\",\"inpi_ct^2\",\"demandeurs_names^0.1\",\"defendeurs_names^0.1\",\"comment_titles^1\",\"citation_titles^0.1\",\"contenu_html^1\",\"saisines_html^2\",\"observations_html^2\",\"sommaire_ana^2\",\"comment_contents^0.5\",\"citation_contents^0.05\"],\"operator\":\"and\"}}],\"filter\":{{#toJson}}filters{{/toJson}}}}",
            "lang" : "mustache",
            "params" : {
              "filters" : [
                {
                  "bool" : {
                    "should" : [
                      {
                        "term" : {
                          "juridiction.raw" : "CE"
                        }
                      }
                    ]
                  }
                },
                {
                  "bool" : {
                    "should" : [
                      {
                        "term" : {
                          "search_access.raw" : "ALL"
                        }
                      },
                      {
                        "term" : {
                          "search_access.raw" : "FREE_TRIAL"
                        }
                      },
                      {
                        "term" : {
                          "search_access.raw" : "RESTRICTED"
                        }
                      }
                    ]
                  }
                }
              ]
            }
          },
          "prune" : true
        }
      }
    }
  }
}}]
org.elasticsearch.transport.RemoteTransportException: [index-dev1][172.31.26.119:9300][indices:data/read/search[phase/query]]
Caused by: org.elasticsearch.ElasticsearchException: I/O exception during suggest phase
    at org.elasticsearch.search.suggest.SuggestPhase.execute(SuggestPhase.java:72) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:94) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:246) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:260) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:298) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:295) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610) [elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596) [elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) [elasticsearch-5.2.0.jar:5.2.0]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [?:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [?:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [?:1.8.0_121]
Caused by: com.fasterxml.jackson.core.JsonParseException: Unexpected character ('}' (code 125)): expected a value
 at [Source: org.elasticsearch.common.bytes.BytesReference$MarkSupportingStreamInputWrapper@8a49262; line: 1, column: 1111]
    at com.fasterxml.jackson.core.JsonParser._constructError(JsonParser.java:1702) ~[jackson-core-2.8.6.jar:2.8.6]
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportError(ParserMinimalBase.java:558) ~[jackson-core-2.8.6.jar:2.8.6]
    at com.fasterxml.jackson.core.base.ParserMinimalBase._reportUnexpectedChar(ParserMinimalBase.java:456) ~[jackson-core-2.8.6.jar:2.8.6]
    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser._handleUnexpectedValue(UTF8StreamJsonParser.java:2656) ~[jackson-core-2.8.6.jar:2.8.6]
    at com.fasterxml.jackson.core.json.UTF8StreamJsonParser.nextToken(UTF8StreamJsonParser.java:832) ~[jackson-core-2.8.6.jar:2.8.6]
    at org.elasticsearch.common.xcontent.json.JsonXContentParser.nextToken(JsonXContentParser.java:55) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.index.query.BoolQueryBuilder.fromXContent(BoolQueryBuilder.java:327) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.SearchModule.lambda$registerQuery$8(SearchModule.java:789) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.xcontent.NamedXContentRegistry.parseNamedObject(NamedXContentRegistry.java:162) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.xcontent.support.AbstractXContentParser.namedObject(AbstractXContentParser.java:369) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.index.query.QueryParseContext.parseInnerQueryBuilder(QueryParseContext.java:116) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.suggest.phrase.PhraseSuggester.innerExecute(PhraseSuggester.java:127) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.suggest.phrase.PhraseSuggester.innerExecute(PhraseSuggester.java:58) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.suggest.Suggester.execute(Suggester.java:46) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.suggest.SuggestPhase.execute(SuggestPhase.java:64) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.query.QueryPhase.execute(QueryPhase.java:94) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.SearchService.loadOrExecuteQueryPhase(SearchService.java:246) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.search.SearchService.executeQueryPhase(SearchService.java:260) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:298) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.action.search.SearchTransportService$6.messageReceived(SearchTransportService.java:295) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.transport.RequestHandlerRegistry.processMessageReceived(RequestHandlerRegistry.java:69) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.transport.TransportService$7.doRun(TransportService.java:610) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.util.concurrent.ThreadContext$ContextPreservingAbstractRunnable.doRun(ThreadContext.java:596) ~[elasticsearch-5.2.0.jar:5.2.0]
    at org.elasticsearch.common.util.concurrent.AbstractRunnable.run(AbstractRunnable.java:37) ~[elasticsearch-5.2.0.jar:5.2.0]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) ~[?:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) ~[?:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) ~[?:1.8.0_121]

你知道我为什么会犯这个错误吗

你的
胡须
模板是错误的,如果你检查你的模板,它被写成
,“filter\:{{{toJson}}filters{{/toJson}}}

toJson
不是标准的
Mustache
功能。它仅在
Elasticsearch
version5.0.0中添加,它将Map解析添加为JSON对象,而不是字符串。此提交仅在
\u search/template
端点中启用此解析


正如您所看到的,
短语建议者所使用的
在5.0.0版中已被弃用,建议使用
搜索模板API

您有没有想法在我的建议查询中实现类似的功能?抱歉@Hugo,我目前没有任何建议。