Commit 18cf36d1 authored by Mathias Goebel's avatar Mathias Goebel 🎠
Browse files

fix return for empty array

parent abb14169
......@@ -247,7 +247,7 @@ as item()* {
(:~
: Provides a simple API for searching the index entries. Used for autocompletion.
: Usually the query should be a simple string. No wildcards, nothing special,
: always case-insensitive.
: always case-insensitive. Only performed for strings larger than one char.
: @param $query A string to search all index entries (names, label, etc.)
: @return $index A list of indices to query, defaults to all, oneOf: listEvent,listOrg,listPerson,listPlace,list-works,list-fontane,list-periodicals.
:)
......@@ -265,7 +265,14 @@ declare
function index:search($query as xs:string, $index)
as array(*) {
let $query := $query => xmldb:decode-uri()
return if(string-length($query) lt 2) then () else
return
if(string-length($query) lt 2)
then []
(: an empty array. explicit array constructor fails in eXist returning somewhat
like a xs:string "Index: 0, Size: 0" from
java.lang.IndexOutOfBoundsException: Index: 0, Size: 0
:)
else (: continue :)
let $prepare := tokenize($index, ",")
let $hits :=
(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment