2012-10-16 9 views
4

을 실행하지 않습니다, 나는 지금 잠시 동안 다음 쿼리 작업을하기 위해 노력하고있어 다음 오류 :탄성 검색 쿼리가 짧게 탄성 검색 자습서를 읽은 후

{ 
    "error": "SearchPhaseExecutionException[Failed to execute phase [query], total failure; shardFailures {[jJz-l-ENSV-0inWp2Sf8Bw][searches][2]: SearchParseException[[searches][2]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n\"query\" :\n{ \n \t\"size\" : \"10\",\n \t\"query\" : {\n\t\t\"bool\" : {\n\t\t\t\"must\" : {\n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : {\n\t\t\t\t\t\t\"text\" : { \"phrase\" : {\"query\" : \"iphone4\", \"type\" : \"phrase_prefix\"}}\n\t\t\t\t\t},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param1\" : 1000\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * param1 \"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"should\" : [{ \n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : { \"match_all\" : {}},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param2\" : 0.001\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * doc['matches'].value * param2 \"\n\t\t\t\t}\n\t\t\t},{\n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : {\"match_all\" : {}},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param3\" : 0.001\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * doc['hits'].value * param3 \"\n\t\t\t\t}\n\t\t\t}]\n\t  \t\n\t\t}\n\t}\n}\n}]]]; nested: QueryParsingException[[searches] [_na] query malformed, no field after start_object]; }{[jJz-l-ENSV-0inWp2Sf8Bw][searches][4]: SearchParseException[[searches][4]: from[-1],size[-1]: Parse Failure [Failed to parse source [{\n\"query\" :\n{ \n \t\"size\" : \"10\",\n \t\"query\" : {\n\t\t\"bool\" : {\n\t\t\t\"must\" : {\n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : {\n\t\t\t\t\t\t\"text\" : { \"phrase\" : {\"query\" : \"iphone4\", \"type\" : \"phrase_prefix\"}}\n\t\t\t\t\t},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param1\" : 1000\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * param1 \"\n\t\t\t\t}\n\t\t\t},\n\t\t\t\"should\" : [{ \n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : { \"match_all\" : {}},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param2\" : 0.001\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * doc['matches'].value * param2 \"\n\t\t\t\t}\n\t\t\t},{\n\t\t\t\t\"custom_score\" : {\n\t\t\t\t\t\"query\" : {\"match_all\" : {}},\n\t\t\t\t\t\"params\" : {\n  \t\t\t\t\t\"param3\" : 0.001\n \t\t\t\t\t },\n\t\t\t\t\t\"script\" : \"_score * doc['hits'].value * param3 \"\n\t\t\t\t}\n\t\t\t}]\n\t  \t\n\t\t}\n\t}\n}\n}]]]; nested: QueryParsingException[[searches] [_na] query malformed, no field after start_object]; }]", 
    "status": 500 
} 

어디에서 내 잘못이라고 생각합니까? 어떻게해야하는지에 대한 제안?

답변

2

중첩 된 쿼리를 외부 쿼리와 "병합"해야합니다. 이 시도 :

{ 
    "query" : { 
     "bool" : { 
      "must" : { 
       "custom_score" : { 
        "query" : { 
         "text" : { "phrase" : {"query" : "iphone4", "type" : "phrase_prefix"}} 
        }, 
        "params" : { 
          "param1" : 1000 
        }, 
        "script" : "_score * param1 " 
       } 
      }, 
      "should" : [{ 
       "custom_score" : { 
        "query" : { "match_all" : {}}, 
        "params" : { 
          "param2" : 0.001 
        }, 
        "script" : "_score * doc['matches'].value * param2 " 
       } 
      },{ 
       "custom_score" : { 
        "query" : {"match_all" : {}}, 
        "params" : { 
          "param3" : 0.001 
        }, 
        "script" : "_score * doc['hits'].value * param3 " 
       } 
      }] 

     } 
    }, 
    "size" : "10" 
} 

당신은 컬을 사용하여 실행하는 경우, 당신은 또한 '\''

'를 교체해야 할 수도 있습니다