2013-07-01 4 views
1

버그인지 또는 누락 된 항목이 있는지 확실하지 않습니다. 그러나 용어 패싯은 용어 개수에 대해 잘못된 개수를 반환합니다.elasticsearch : 용어면에서 잘못 계산 됨

나는 필드가 str_tag_analyzer입니다.

필드에서 태그 클라우드를 가져오고 싶습니다. 나는 그들의 카운트와 함께 최고 20 개의 태그를 얻고 싶습니다. (등장 횟수).

이 경우에 패싯이 해결책을 찾았습니다. 용어 패싯 쿼리의 크기 매개 변수는 반환되는 태그 수를 제어한다는 것을 알고 있습니다.

다른 크기의 용어 패싯 쿼리를 실행할 때 예기치 않은 결과가 발생합니다. 다음은 내 검색어 및 그 결과입니다.

쿼리 1

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d ' 
{ 
query : { 
    "nested" : { 
    "query" : { 
     "field" : { 
     "gsid" : 222 
     } 
    }, 
    "path" : "medals" 
    } 
}, from: 0, size: 0 
, 
facets: { 
"tags" : { "terms" : {"field" : "field_val_t", size: 1} } 
} 
}' 


{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 189, 
    "max_score" : 1.0, 
    "hits" : [ ] 
    }, 
    "facets" : { 
    "tags" : { 
     "_type" : "terms", 
     "missing" : 57, 
     "total" : 331, 
     "other" : 316, 
     "terms" : [ { 
     "term" : "hyderabad", 
     "count" : 15 
     } ] 
    } 
    } 

쿼리 2

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d ' 
{ 
query : { 
    "nested" : { 
    "query" : { 
     "field" : { 
     "gsid" : 222 
     } 
    }, 
    "path" : "medals" 
    } 
}, from: 0, size: 0 
, 
facets: { 
"tags" : { "terms" : {"field" : "field_val_t", size: 3} } 
} 
}' 


{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 189, 
    "max_score" : 1.0, 
    "hits" : [ ] 
    }, 
    "facets" : { 
    "tags" : { 
     "_type" : "terms", 
     "missing" : 57, 
     "total" : 331, 
     "other" : 282, 
     "terms" : [ { 
     "term" : "playing", 
     "count" : 20 
     }, { 
     "term" : "hyderabad", 
     "count" : 15 
     }, { 
     "term" : "pune", 
     "count" : 14 
     } ] 
    } 
    } 
} 

쿼리 3

curl -XGET 'http://server:9200/stage_profiles/wrapper_0/_search?pretty=1' -d ' 
{ 
query : { 
    "nested" : { 
    "query" : { 
     "field" : { 
     "gsid" : 222 
     } 
    }, 
    "path" : "medals" 
    } 
}, from: 0, size: 0 
, 
facets: { 
"tags" : { "terms" : {"field" : "field_val_t", size: 10} } 
} 
}' 
{ 
    "took" : 1, 
    "timed_out" : false, 
    "_shards" : { 
    "total" : 3, 
    "successful" : 3, 
    "failed" : 0 
    }, 
    "hits" : { 
    "total" : 189, 
    "max_score" : 1.0, 
    "hits" : [ ] 
    }, 
    "facets" : { 
    "tags" : { 
     "_type" : "terms", 
     "missing" : 57, 
     "total" : 331, 
     "other" : 198, 
     "terms" : [ { 
     "term" : "playing", 
     "count" : 20 
     }, { 
     "term" : "hyderabad", 
     "count" : 19 
     }, { 
     "term" : "bangalore", 
     "count" : 18 
     }, { 
     "term" : "pune", 
     "count" : 16 
     }, { 
     "term" : "chennai", 
     "count" : 16 
     }, { 
     "term" : "games", 
     "count" : 13 
     }, { 
     "term" : "testing", 
     "count" : 11 
     }, { 
     "term" : "cricket", 
     "count" : 9 
     }, { 
     "term" : "singing", 
     "count" : 6 
     }, { 
     "term" : "movies", 
     "count" : 5 
     } ] 
    } 
    } 
} 

나는이 다음과 같은 문제 1. 첫 번째 쿼리는, 15의 카운트 태그를주고 있지만, 카운트 20 (쿼리 2와 3에서 볼 수있는)이있는 또 다른 태그가 있습니다. 그래서 count 20을 가진 "playing"태그를 반환해야합니다. 2. 두 번째 쿼리는 "hyderabad"태그의 카운트를 15로 반환하지만 세 번째 쿼리는 같은 태그에 대해 19로 카운트를 반환합니다.

맵핑, ES에있는 데이터와 같은 다른 정보가 필요한 경우 알려주십시오. 감사합니다.

답변

1

그것은 known issue입니다. 해결 방법은 단일 샤드를 사용하거나 표시 할 단어를 더 요청하는 것입니다.

+0

버전 0.90.6 이후 ['shard_size'] (http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/search-facets-terms-facet.html#_accuracy_control)를 사용할 수도 있습니다. . – Sonson123

+0

이것을 달성하는 최선의 방법은 아닙니다. 단일 샤드를 사용하면 성능에 영향을 미칠 수 있습니다. – eliasah