2
ElasticSearch 버전 수행 할 때 : 0.90.2유형 캐스트 예외 custom_score 쿼리
내가 점수 최신 성으로 문서,하지만 모두가 지금까지있어 너무 작업 custom_score 쿼리를 얻으려고하는 것은
ClassCastException[org.elasticsearch.index.fielddata.ScriptDocValues$Longs cannot be cast to java.lang.Integer]
입니다
아이디어는 정수 형식 타임 스탬프가있는 필드로 문서를 인덱싱 한 다음 쿼리에서 현재 타임 스탬프 매개 변수를 전달하는 것과 비교하는 것이 었습니다. 어떻게 색인 된 정수 값이 길어 졌습니까? 여기
는 명령을 재현 할 수 있습니다 :curl -XPUT 'http://localhost:9200/test_longs_problem/'
curl -XPUT 'http://localhost:9200/test_longs_problem/albums/_mapping' -d '
{
"albums" : {
"properties" : {
"date" : {"type" : "integer", "analyzed" : false}
}
}
}'
curl -XPUT 'http://localhost:9200/test_longs_problem/albums/1' -d '
{
"date" : 1376823903
}'
curl -XGET 'http://localhost:9200/test_longs_problem/albums/_search?pretty' -d '{
"query": {
"custom_score": {
"query": {
"match_all": {}
},
"params": {
"now": 1376823903
},
"script": "_score * 0.2/(3.16 * pow(10, -9) * abs(now - doc[\"date\"]) + 0.05) + 1.0"
}
}
}'
는
{
"error" : "SearchPhaseExecutionException[Failed to execute phase [query_fetch], total failure; shardFailures {[NSdeWzwNSIeLtGA1mtLTyA][test_longs_problem][0]: QueryPhaseExecutionException[[test_longs_problem][0]: query[filtered(custom score (ConstantScore(*:*),function=script[_score * 0.2/(3.16 * pow(10, -9) * abs(now - doc[\"date\"]) + 0.05) + 1.0], params [{[email protected], now=1376823903, [email protected], [email protected], [email protected], _score=1.0}]))->cache(_type:albums)],from[0],size[10]: Query Failed [Failed to execute main query]]; nested: CompileException[[Error: uncomparable values <<1376823903>> and <<[email protected]>>]\n[Near : {... _score * 0.2/(3.16 * pow(10, ....}]\n ^\n[Line: 1, Column: 1]]; nested: RuntimeException[uncomparable values <<1376823903>> and <<[email protected]>>]; nested: ClassCastException[org.elasticsearch.index.fielddata.ScriptDocValues$Longs cannot be cast to java.lang.Integer]; }]",
"status" : 500
}