That would be adding information to the properties that was already in the 
document. Hopefully there's some better way.

From: [email protected]
To: [email protected]
Date: Wed, 18 Aug 2010 15:14:17 -0700
Subject: Re: [MarkLogic Dev General] How to query all docs and sort by 
last-modified property?



















If you added an <image> element to the properties for each
document that was an image then I think an additional query would work.

 





From:
[email protected]
[mailto:[email protected]] On Behalf Of 
[email protected]

Sent: Wednesday, August 18, 2010 3:08 PM

To: [email protected]

Subject: Re: [MarkLogic Dev General] How to query all docs and sort by
last-modified property?





 

This is really close to what I need. Now I
just need to constrain the results to only be for documents that have
"image" for the root element. I tried adding this to the search
options:



<additional-query>/image</additional-query>



but it didn't affect the results. I suppose because the "image"
elements are already being retrieved by the searchable expression, adding any
additional-query with do nothing, since everything is already satisfied in the
properties query. 



So how I can I just return the image documents, and sort them by last-modified?







From: [email protected]

To: [email protected]

Date: Wed, 18 Aug 2010 14:51:49 -0700

Subject: Re: [MarkLogic Dev General] How to query all docs and sort by
last-modified property?



If you search over the properties you can get this to
work.  I cannot immediately think of how you can do this using the search
API without searching over the properties.  Here is how to do it by
searching over the properties (you need a dateTime range index on
prop:last-modified for this to be optimized):

 

xquery version "1.0-ml";

 

import module namespace search =
"http://marklogic.com/appservices/search";

at "/MarkLogic/appservices/search/search.xqy";

declare namespace
prop="http://marklogic.com/xdmp/property";;

 

let $options := 

<options xmlns="http://marklogic.com/appservices/search";>

  <searchable-expression>xdmp:document-properties() 

  </searchable-expression>

  <debug>true</debug>

  <term>

   <empty apply="all-results" />

  </term>

  <sort-order type="xs:dateTime"
direction="descending">

    <element
ns="http://marklogic.com/xdmp/property";
name="last-modified"/>

  </sort-order>

</options>

 

return

search:search("", $options)

 

-Danny

 





From:
[email protected]
[mailto:[email protected]] On Behalf Of 
[email protected]

Sent: Wednesday, August 18, 2010 1:02 PM

To: [email protected]

Subject: [MarkLogic Dev General] How to query all docs and sort by
last-modified property?





 

I
have xml files in the database with the root element of “image”. What I want to
do is to use search:search to query all the image elements (no search term) and
order them by the last-modified property. 

 

Below
is what I have tried, but it doesn’t seem to actually be sorting on the
last-modified property (I do already have an element range index on the
property). It just returns hits based on relevance which is meaningless in this
type of query.

 

Does
anyone know how I can get this to work?

 

xquery
version '1.0-ml';

 

import
module namespace search = "http://marklogic.com/appservices/search";
at "/MarkLogic/appservices/search/search.xqy";

 

let
$options := 

     
<options xmlns="http://marklogic.com/appservices/search";>

           
<searchable-expression 
xmlns="http://marklogic.com/appservices/search";>/image</searchable-expression>

           
<search:sort-order type="xs:dateTime"
direction="descending">

     
           
<search:element ns="http://marklogic.com/xdmp/property";
name="last-modified"/>

     
      </search:sort-order>

     
</options>

 

return
search:search("", $options, 1, 16)





_______________________________________________ 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

Reply via email to