Hi,
With the hint that it is sorting related, I looked back at the stack-trace, and I notice that $qtext had an incomplete search expression: $qtext = "sort:" That could be what threw off the search qtext parser.. Cheers, Geert *Van:* [email protected] [mailto: [email protected]] *Namens *Charles Greer *Verzonden:* dinsdag 3 december 2013 19:24 *Aan:* [email protected] *Onderwerp:* Re: [MarkLogic Dev General] [BULK] Re: XPTY0004 $right as element() Error Hi Maggie, Would you mind sharing the fixed sort-order configuration? I'm actually investigating what the limits are for how to configure sort order. Charles On 12/03/2013 08:23 AM, Capewell, Margarete wrote: Case closed! There was an issue with the way the sort operator was set-up. Thanks for the replies! -Maggie On Dec 3, 2013, at 8:48 AM, "Capewell, Margarete" < [email protected]> wrote: Hi Geert, I wrote the facet code myself without using app builder. I'm thinking the problem lies in the *format-browse-by-collection* function (the last function included below), but I'm not sure. I'll try to clarify by including some code. Thanks for taking a look. Facet set-up is like so: <options *xmlns*=*"http://marklogic.com/appservices/search <http://marklogic.com/appservices/search>"*> <additional-query>{*cts:collection-query*("MODS")}</additional-query> <constraint *name*=*"collection"*> <word *type*=*"xs:string"* *collation*=*"http://marklogic.com/collation/en/S1/AS/T0020 <http://marklogic.com/collation/en/S1/AS/T0020>"*> <path-index *xmlns:mods*=*"http://www.loc.gov/mods/v3 <http://www.loc.gov/mods/v3>"* >/mods:modsCollection/mods:mods/mods:titleInfo[@type='uniform']/mods:title</path-index> </word> </constraint> <operator *name*=*"sort"*> <state *name*=*"relevance"*> <sort-order> <score/> </sort-order> </state> <state *name*=*"collection"*> <sort-order *xmlns*=*"http://marklogic.com/appservices/search <http://marklogic.com/appservices/search>"* *type*=*"xs:string"*> {*m:get-sort-direction*(*$direction*)} <range *type*=*"xs:string"* *collation*=*"http://marklogic.com/collation/en/S1/AS/T0020 <http://marklogic.com/collation/en/S1/AS/T0020>"*> <path-index *xmlns:mods*=*"http://www.loc.gov/mods/v3 <http://www.loc.gov/mods/v3>"* >/mods:modsCollection/mods:mods/mods:titleInfo[@type='uniform']/mods:title</path-index> </range> </sort-order> </state> </operator> </options> (:~ : Retrieves all collection titles from the database. Returns results in a simple : ad-hoc XML format (rather than the raw search results). :) *declare function **m:get-collections*() *as **element*(*search:response*) { *let $options* := <options *xmlns*=*"http://marklogic.com/appservices/search <http://marklogic.com/appservices/search>"*> <return-results>false</return-results> <return-facets>true</return-facets> <additional-query>{*cts:collection-query* ("MODS")}</additional-query> <constraint *name*=*"collection"* *xmlns*=*"http://marklogic.com/appservices/search <http://marklogic.com/appservices/search>"*> <range *type*=*"xs:string"* *facet*=*"true"* *collation*=*"http://marklogic.com/collation/en/S1/AS/T0020 <http://marklogic.com/collation/en/S1/AS/T0020>"*> <path-index *xmlns:mods*=*"http://www.loc.gov/mods/v3 <http://www.loc.gov/mods/v3>"* >/mods:modsCollection/mods:mods/mods:titleInfo[@type='uniform']/mods:title</path-index> </range> </constraint> </options> *let* *$qtext* := "" *return **search:search*(*$qtext*, *$options*) }; I have the formatting set-up in a separate module like so: (: Returns an HTML fragment for the main content of the browse-by-collection page. :) *declare function **browse:get-collections*(*$params* *as map:map*) *as **element*(*div*)* { *let $response* := *m:get-collections*() *return **browse:format-browse-by-collection*(*$response*) }; (:~ Formats collection titles for browsing purposes. :) *declare function **browse:format-browse-by-collection*(*$response* *as * *element*(*search:response*)) *as **element*(*div*)* { *for $facet-value* *at* *$i* *in $response*/*search:facet*/ *search:facet-value* *let* *$collection* := *fn:normalize-space*(*fn:string*(*$facet-value*)) *let* *$count* := *$facet-value*/*@count* *let* *$label* := *if* (*$count* = 1) *then *" item" *else *" items" *let* *$constraint* := *if* (*$c:by* = "collection") *then *"collection" *else *() *let* *$qtext* := *fn:concat*(*$constraint*, ':"', *$collection*, '" sort:', *$c:sort*) *let* *$href* := *fn:concat*(*$config:base-url*, "?browse=", *$c:browse*, "&qtext=", *xdmp:url-encode*(*$qtext*), "&page-length=", *$c:page-length*) *return * <div *class*=*"*{*if* (*$i* mod 2 = 0) *then *"even-row" *else * "odd-row"}*"*> <ul *class*=*"browse-collections-list"*> <li><a *href*=*"*{*$href*}*"* *class*=*"name-entries"*>{ *$collection*}</a> ({*fn:concat*(*ptsl-util:format-number*(*$count*), *$label*)})</li> </ul> </div> }; On Dec 2, 2013, at 4:44 PM, Geert Josten <[email protected]> wrote: Hi Maggie, Are you running an app created with app builder, or did you write facet code of your own? In either case, could you give a bit more detail about what you are trying or using? A bit of code might help.. Kind regards, Geert *Van:* [email protected] [mailto: [email protected]] *Namens *Capewell, Margarete *Verzonden:* maandag 2 december 2013 22:33 *Aan:* MarkLogic Developer Discussion *Onderwerp:* [MarkLogic Dev General] XPTY0004 $right as element() Error Hello, I have a group of facets set-up using search:search, but when I click on the links to get the constrained results I receive the following error: XDMP-AS: (err:XPTY0004) $right as element() -- Invalid coercion: () as element() in /MarkLogic/appservices/search/search-impl.xqy, at 692:13, in impl:joiner-constraint(map:map(<map:map xmlns:xs=" http://www.w3.org/2001/XMLSchema" xmlns:xsi=" http://www.w3.org/2001/XMLSchema-instance" xmlns:map=" http://marklogic.com/xdmp/map"><map:entry key="toknum"><map:value xsi:type="xs:unsignedLong">11...</map:map>...XDMP-XMLFUNC: (err:XQTY0105) Functions cannot be used in the content of an element constructor...), <cts:word-query qtextref="cts:text" xmlns:cts="http://marklogic.com/cts"><cts:text>sort</cts:text><cts:option>case-insensitive</cts:optio...</cts:word-query>) [1.0-ml] $ps = map:map(<map:map xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:map=" http://marklogic.com/xdmp/map"><map:entry key="toknum"><map:value xsi:type="xs:unsignedLong">11...</map:map>...XDMP-XMLFUNC: (err:XQTY0105) Functions cannot be used in the content of an element constructor...) $left = <cts:word-query qtextref="cts:text" xmlns:cts=" http://marklogic.com/cts "><cts:text>sort</cts:text><cts:option>case-insensitive</cts:optio...</cts:word-query> $left-str = "sort" $opts = <options xmlns="http://marklogic.com/appservices/search"><additional-query><cts:collection-query xmlns:cts="http://marklo...</options> $matched-constraint = <operator name="sort" xmlns=" http://marklogic.com/appservices/search"><state name="relevance"><sort-order><score/></sort-order></state...</operator> $is-bucketed = () $symbol = <joiner strength="50" apply="constraint" xmlns=" http://marklogic.com/appservices/search" xmlns:searchdev=" http://marklogic.com/appservices/search/searchdev">:</joiner> $compare = "EQ" $_ = () $right = () $bucket-name = "" $qtext-rhs = "" $qtext = "sort:" in /MarkLogic/appservices/search/search-impl.xqy, at 503:50, ...and it just goes on from there. I'm guessing the $right variable has something to do with the search results, but I'm not sure what I need to do to fix the issue. Has anyone dealt with a similar error? Any ideas on how to fix it? Thank you, Maggie _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general _______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general -- Charles Greer Senior Engineer MarkLogic Corporation [email protected] Phone: +1 707 408 3277 www.marklogic.com
_______________________________________________ General mailing list [email protected] http://developer.marklogic.com/mailman/listinfo/general
