0
我想整理我的基礎上嵌套(就業)對象的個數公司的結果,Elasticsearch - foselastica的整數排序有奇怪的結果
我增加了一個額外的字段來保存像數的公司實體:
private employeeCount;
getEmployeeCount(){
return count($this->employments);
}
,並把它添加到像指數:
company:
mappings:
fullname: ~
employeeCount: ~
領域的正確索引,我得到的點擊,如:
"_hit": {
"_index": "search",
"_type": "company",
"_id": "2628",
"_source": {
"fullname": "acme",
"employeeCount": 9,
... },
"sort": [
"9"
]
我加了有點像:
$query->addSort(array('employeeCount' => array('order'=>'desc')));
,結果似乎是從 「9,8,7,6 ...」 正確地向下排序,
但由於某種原因也有一些成果在中間某個地方具有較高EMPLOYEECOUNT
例如這樣的:
"_hit": {
"_index": "search",
"_type": "company",
"_id": "2668",
"_source": {
"fullname": "acme2",
"employeeCount": 18,
... },
"sort": [
"18"
]
我希望這個結果是對我的第一個例子的頂部,但它是某處被忽略
或有2和1之間
於是兩個猜測,它是從0-10排序一切大於10在elasticsearch或foselastica捆綁了一些bug,
繼承人結果查詢:
search/company/_search (GET) 5.59 ms {"sort":[{"employeeCount":{"order":"desc"}}],"query":{"wildcard":{"fullname":{"value":"**","boost":1}}},"size":"2000","from":0}
有誰知道?
我有同樣的問題,你有沒有找到答案? – parisssss
不幸的是我沒有找到任何解決方案。隨意請求開發人員,我沒有 –
我在這裏找到答案:) http://stackoverflow.com/questions/25199481/elasticsearch-sorting-integer-desc#answer-25200046 – parisssss