HI.

This is interesting and something I'm going to play around with.

However, the issue is probably a somewhat logical explanation when you
consider that there is no guaranteed order of execution in a FLWOR
statement - I believe.

- in the extract-metadata solution, the data you want exists before you
start to iterate over the results.

- in the FLWOR expression, there is much more involved in the possible
order of the results based on what you are doing in the expression - unless
you also explicitly add an order by statement. The crazy complexity of this
can be previewed here:  http://www.w3.org/TR/xquery/#id-orderby-return

- So, once you start doing things in the FLWOR expression such as variable
assignment and function calls and do not specifically include an order-by
statement, then all bets are off as to the final order.

Kind Regards,
David Ennis



Kind Regards,
David Ennis


David Ennis
*Content Engineer*

[image: HintTech]  <http://www.hinttech.com/>
Mastering the value of content
creative | technology | content

Delftechpark 37i
2628 XJ Delft
The Netherlands
T: +31 88 268 25 00
M: +31 63 091 72 80

[image: http://www.hinttech.com] <http://www.hinttech.com>
<https://twitter.com/HintTech>  <http://www.facebook.com/HintTech>
<http://www.linkedin.com/company/HintTech>

On 28 October 2014 19:36, Hasegawa, Margarete <[email protected]>
wrote:

>  That's very interesting. I dropped the flwor and used <extract-metadata>
> to get the titles instead and the order of the results returned is
> different. What is it about the two different methods (flwor vs.
> <extract-metadata>) that causes the order to change?
>
>  Thanks,
> Maggie
>
>   From: Dave Cassel <[email protected]>
> Reply-To: MarkLogic Developer Discussion <[email protected]>
> Date: Tuesday, October 28, 2014 2:05 PM
> To: MarkLogic Developer Discussion <[email protected]>
> Subject: Re: [MarkLogic Dev General] Diacritic-insensitive collation
> ignored
>
>    Not sure, but perhaps running a flwor on the results of search:search
> is affecting the ordering. From the snippet you've shown, it looks like
> you're looping through to get the titles, which you could also do using
> <extract-metadata>
> <http://docs.marklogic.com/guide/rest-dev/appendixb#id_94425>. If you
> drop the FLWOR and just look at the results from search:search, do you get
> the order you expect?
>
>  --
> Dave Cassel
> Developer Community Manager
> MarkLogic Corporation <http://www.marklogic.com/>
> Cell:  +1-484-798-8720
>
>
>   From: <Hasegawa>, Margarete <[email protected]>
> Reply-To: MarkLogic Developer Discussion <[email protected]>
> Date: Tuesday, October 28, 2014 at 1:34 PM
> To: "[email protected]" <[email protected]>
> Subject: [MarkLogic Dev General] Diacritic-insensitive collation ignored
>
>   Hi,
>
>  I'm working on an application that uses the Search API and I am trying
> to set the collation on an element range index to be diacritic insensitive.
> However, the same results are returned in the same order regardless of the
> collation that I use. We are using Marklogic 7. Has anyone encountered a
> similar problem before? If so, any thoughts on how to solve it?
>
>  Thanks,
> Maggie
>
>  Here is the simplified version of the search:
>
>  declare variable $options :=
>   <options xmlns="http://marklogic.com/appservices/search";>
>       <constraint name="title">
>       <word>
>         <element ns="http://digital.library.ptsem.edu/ia"; name="title"/>
>       </word>
>     </constraint>
>     <transform-results apply="empty-snippet"/>
>     <operator name="sort">
>      <state name="title">
>        <sort-order xmlns="http://marklogic.com/appservices/search";
> type="xs:string">
>         <element ns="http://digital.library.ptsem.edu/ia";
> name="sortTitle" collation="http://marklogic.com/collation/en/S1/AS/T0020";
> />
>        </sort-order>
>      </state>
>     </operator>
>   </options>;
> let $response:= search:search("title:Viage literario", $options, 1, 500)
> let $total := $response/@total
> for $result in $response/search:result
> let $uri := $result/@uri
> let $doc := fn:doc($uri)
> let $title := $doc/ia:doc/ia:metadata/ia:sortTitle
> let $vol := $doc/ia:doc/ia:metadata/ia:volumeInfo/ia:volume
> Return fn:string($title)
>
>  Here are the results that I am seeing:
>
>    Viage literario á iglesias de España
>  Viage literario á iglesias de España
>  Viage literario á iglesias de España
>  Viage literario á iglesias de España
>  Viage literario a las iglesias de Espana
>  Viage literario á iglesias de España
>  Viage literario a las iglesias de Espana
>  Viage literario á iglesias de España
>  Viage literario á iglesias de España : Le Publica con algunas
> observaciones
>  Viage literario á iglesias de España
>  Viage literario a las iglesias de Espana
>  Viage literario á iglesias de España
>  Viage literario a las iglesias de Espana
>  Viage literario a las iglesias de Espana
>  Viage literario a las iglesias de Espana
>  Viage literario a las iglesias de Espana
>  Viage literario a las iglesias de Espana
>
>
> _______________________________________________
> General mailing list
> [email protected]
> http://developer.marklogic.com/mailman/listinfo/general
>
>
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to