I would like to make the ordering to be based on Hungarian sort order - for example: "aábc..z" instead of "abc..zá". So I would need to set the locale /collation to Hungarian.
My pipeline:
[0] => array[1]
(
[$match] => array[1]
(
[$and] => array[2]
(
[0] => array[1]
(
[aktiv] => true (boolean)
)
[1] => array[1]
(
[aktivGondozott] => true (boolean)
)
)
)
)
[1] => array[1]
(
[$project] => array[2]
(
[_id] => 1 (int)
[alapadatok] => array[1]
(
[$arrayElemAt] => array[2]
(
[0] => '$alapadatok' (string)
[1] => 0 (int)
)
)
)
)
[2] => array[1]
(
[$project] => array[3]
(
[_id] => 1 (int)
[teljesNev] => '$alapadatok.szuletesiTeljesNev' (string)
[szuletesiDatum] => '$alapadatok.szuletesiIdo' (string)
)
)
[3] => array[1]
(
[$sort] => array[1]
(
[teljesNev] => 1 (int)
)
)
[4] => array[1]
(
[$skip] => 380 (int)
)
[5] => array[1]
(
[$limit] => 20 (int)
)
How to set locale to 'hu' at $sort in collection::aggregate() ?
Thank You!
Set the locale in the collation document and pass it as aggregation options.
$m = new MongoClient;
$c = $m->selectDB("db")->selectCollection("col");
$pipeline = some pipeline
$options = array("collation" => array("locale" => "hu"));
$c->aggregate($pipeline, $options);