Hi Jonna,


Or you could use the search constraint you already defined. You can either
point to the bucket you are defining on the fly like this:



search:search(“book daterange:daterange”, $options)



but you could also write it like this:



search:search(“book AND daterange GT 2013-10-27T09:46:35.454794-04:00 AND
daterange LT 2013-10-28T09:46:35.454794-04:00”, $options)



Which way suites you best likely depends on your functional requirements,
and which of these approaches fits those best..



Kind regards,

Geert



*Van:* [email protected] [mailto:
[email protected]] *Namens *Arindam3 B
*Verzonden:* dinsdag 29 oktober 2013 8:53
*Aan:* MarkLogic Developer Discussion
*CC:* General Mark Logic Developer Discussion;
[email protected]
*Onderwerp:* Re: [MarkLogic Dev General] Date range constrain in
search:search()



Hi Jonna,

You can use a *cts:element-range-query* and add that to the
<additional-query> tag within your search options.

 <options xmlns="http://marklogic.com/appservices/search";>
......
<additional-query>
cts:and-query((
cts:element-range-query(xs:QName("datetime"),">=",$from),
cts:element-range-query(xs:QName("datetime"),"<=",$to)
))
</additional-query>
</options>



Thanks & Regards
Arindam

From:

Jonna Marry <[email protected]>

To:

General Mark Logic Developer Discussion <[email protected]>

Date:

10/29/2013 01:11 PM

Subject:

[MarkLogic Dev General] Date range constrain in search:search()

Sent by:

[email protected]


------------------------------




Hi,

I have a requirement to search a term within a date range. I have created a
date constrain as given below and used search:search()

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

let $from := "2013-10-27T09:46:35.454794-04:00"
let $to := "2013-10-28T09:46:35.454794-04:00"
let $options :=  <options xmlns="http://marklogic.com/appservices/search";>
<constraint name="daterange">
       <range type="xs:dateTime" facet="true">
         <bucket name="daterange" ge="{$from}" lt="{$to}">Date
Range</bucket>
         <facet-option>frequency-order</facet-option>
         <facet-option>descending</facet-option>
         <facet-option>limit=10</facet-option>
         <element  name="datetime"/>
       </range>
</constrain>
</options>

let $result := search:search("book",$options)
return $result


I am getting the 100 results of "book"  and facet result for date range as
6
<search:facet name="daterange">
   <search:facet-value name="daterange" count="6">Date
Range</search:facet-value>
 </search:facet>

Actually i want the *search results within that date range*. How to add the
date range dynamically in search:search() query.

Regards,

Jonna_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

=====-----=====-----=====
Notice: The information contained in this e-mail
message and/or attachments to it may contain
confidential or privileged information. If you are
not the intended recipient, any dissemination, use,
review, distribution, printing or copying of the
information contained in this e-mail message
and/or attachments to it are strictly prohibited. If
you have received this communication in error,
please notify us by reply e-mail or telephone and
immediately and permanently delete the message
and any attachments. Thank you
_______________________________________________
General mailing list
[email protected]
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to