[MarkLogic Dev General] Sort by issue over element with same name
Mike Sokolov
sokolov at ifactory.com
Thu Oct 13 12:25:52 PDT 2011
I'm not sure about the performance impact of searching on documents, and
then sorting on properties. We generally wrap all of our documents, as
Mike indicated (same element names, actually :), but in a private
namespace ). But I'd be curious if there are arguments why this could
be done better with properties docs. I've always assumed the wrapping
approach would lead to (maybe slightly) better performance, but without
any evidence to back it up.
-Mike
On 10/13/2011 02:14 PM, Geert Josten wrote:
> Hi Greg,
>
> I am afraid not just using the current functionality of the search:search library, though you could try to post it as RFE. They might think of a way to add it somehow.
>
> Another option is to do so yourself with a FLOWR, but that would mean you won't be able to use the pagination features of search:search.
>
> You could also compose a single string to use for sorting, and store that among the document-properties. That way you don't change the original XML, but still have a way to add an easy string to use for sorting.
>
> Kind regards,
> Geert
>
> -----Oorspronkelijk bericht-----
> Van: general-bounces at developer.marklogic.com [mailto:general-bounces at developer.marklogic.com] Namens Murray, Gregory
> Verzonden: donderdag 13 oktober 2011 19:46
> Aan: General MarkLogic Developer Discussion
> Onderwerp: Re: [MarkLogic Dev General] Sort by issue over element with same name
>
> I don't see any responses yet for this thread. I have the same problem described in the original post. In my case, I need to sort search results by last name, then by first name. The two name parts have the same element name and are disambiguated by an attribute:
>
> <mods xmlns="http://www.loc.gov/mods/v3">
> <name type="personal">
> <namePart type="given">Gregory P.</namePart>
> <namePart type="family">Murray</namePart>
> </name>
> </mods>
>
> When setting up a sort operator in the options for search:search(), sorting by<namePart> just won't cut it:
>
> <options xmlns="http://marklogic.com/appservices/search">
> <operator name="sort">
> <state name="name">
> <sort-order type="xs:string">
> <element ns="http://www.loc.gov/mods/v3" name="namePart"/>
> </sort-order>
> </state>
> </operator>
> </options>
>
> Doing this instead:
>
> <element ns="http://www.loc.gov/mods/v3" name="namePart[@type="family"]"/>
>
> raises an "Invalid lexical value" error, since that's not a valid element name. But that's the kind of thing I need -- some kind of qualifier with which I can tell search:search() to sort by namePart[@type="family"]. Is something like that possible? I'd much prefer that, as opposed to changing the underlying XML documents.
>
> Many thanks,
> Greg
>
> Gregory Murray
> Digital Library Application Developer
> Princeton Theological Seminary
>
>
> On Aug 22, 2011, at 12:04 PM, Abhishek53 S wrote:
>
>
>> Hi Folks
>>
>> I am using search:search API to get the result from ML.I want to sort the result based on the "element title whose parent element does not have any index attribute" i.e. sorting over first title element in the sample xml. This seems to be impossible to me as the range indexing is created over the leaf element or element- attribute pair only..
>>
>> I guess the only option is to restructure the content...Let me know if you have any other solution to over come the issue.....
>>
>> <root>
>> <parent>
>> <title>XXXXX</title>
>> </parent>
>> <parent index="A">
>> <title>XXXXX</title>
>> </parent>
>> <parent index="B">
>> <title>XXXXX</title>
>> </parent>
>> <parent index="C">
>> <title>XXXXX</title>
>> </parent>
>> </root>
>>
>> Thanks in advance
>> Abhishek Srivastav
>> Tata Consultancy Services
>> Cell:- +91-9883389968
>> Mailto: abhishek53.s at tcs.com
>> Website: http://www.tcs.com
>>
>
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
> _______________________________________________
> General mailing list
> General at developer.marklogic.com
> http://developer.marklogic.com/mailman/listinfo/general
>
More information about the General
mailing list