Hi, I'm trying to write a faceted search with exist and xquery. What I have so far is:
xquery version "1.0"; declare namespace request="http://exist-db.org/xquery/request"; declare namespace xs="http://www.w3.org/2001/XMLSchema"; declare option exist:serialize "method=xml media-type=text/xml omit-xml-declaration=no indent=yes"; let $label:= request:get-parameter("l",'0') let $dateTo:= request:get-parameter("dt",'0') let $dateFrom := request:get-parameter("df",'0') let $person := request:get-parameter("p",'0') let $officesHeld := request:get-parameter("o",'0') let $off := request:get-parameter("off",'0') let $num := request:get-parameter("num",'10') return <xml> { subsequence(//foo/bar[ (: label :) (if ($label = '0') then ( * )else( label/@val = $label )) and (: person :) (if ($person = '0') then ( * )else( contributions/person/@val = $person )) and (: offices held :) (if ($officesHeld = '0') then ( * )else( contributions/offices_held/@val = $officesHeld )) ],$off,$num) } </xml> On my local machine this runs fine but on my server I get FORG0001: xs:string(0) is not a sub-type of xs:double [at line 18, column 9]. Also the performance is really bad. Is there a better way to do a faceted search? I want to say, if there is a parameter in the URL that matches $person then search for a person that matches something similar to the value of the person element. And if the parameter isn't in the url don't search for it, the way I thought about getting around that is by putting in *, and then building up a search query based on that. But this seems really inefficient. I haven't fully done an index of the exist-db yet. But can anyone see a better way to do this search? Thanks
_______________________________________________ [email protected] http://x-query.com/mailman/listinfo/talk
