You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
sapi:autocomplete function is a part of the search.xql module.
Retrieving data can be modified or implemented in a custom autocomplete($doc, $type, $q) function.
Unfortunately, the returned results do not keep their order, but are sorted according to the following code in the sapi:autocomplete function:
array {
for $item in $items
groupby $item
return
map {
"text": $item,
"value": $item
}
}
It is useful for the user experience if the suggestions are ordered in the expected way, i.e. alphabetically in the case of text or numerically in the case of numbers.
It seems that group by in the mentioned code is used to keep unique values from the returned set, but it also changes the sorting of items in the $items variable.
I suggest three ways how to set expected order of suggestions:
1. Simple (it assumes that returned values are sorted):
for $item indistinct-values($items) (: instead of group by :)
2. Advanced (it assumes that all suggestions will be sorted in the same way):
In search.xql:
for $item insort(distinct-values($items), $config:default-autocomplete-collation)
sapi:autocomplete
function is a part of the search.xql module.Retrieving data can be modified or implemented in a custom
autocomplete($doc, $type, $q)
function.Unfortunately, the returned results do not keep their order, but are sorted according to the following code in the
sapi:autocomplete
function:It is useful for the user experience if the suggestions are ordered in the expected way, i.e. alphabetically in the case of text or numerically in the case of numbers.
It seems that
group by
in the mentioned code is used to keep unique values from the returned set, but it also changes the sorting of items in the$items
variable.I suggest three ways how to set expected order of suggestions:
1. Simple (it assumes that returned values are sorted):
2. Advanced (it assumes that all suggestions will be sorted in the same way):
In
search.xql
:In
config.xqm
:3. Customized (with the greatest degree of control over sorting):
In
search.xql
:In
config.xqm
:The text was updated successfully, but these errors were encountered: