Hi David,

Your property has a dateTime value, and you have setup your index correctly. 
You are passing in a date value in your search though. Append a time section to 
your date string, and cast to dateTime, or wrap the date in an extra dateTime 
cast:

xs:dateTime(“2011-01-01T00:00:00”) or xs:dateTime(xs:date(“2011-01-01”))


Keep in mind that the second will append T00:00:00 as well, meaning <= 
2011-01-01 will effectively not include 2011-01-01 itself. Consider using 
xs:dateTime(“2011-01-01T00:00:00”) + xs:dayTimeDuration(“P1D”), which adds one 
day to the compare date..


As for the search:search call, you have the fragment-scope option in search 
options, but that allows you to pick only properties or documents, not both. It 
can be useful for facets driven from doc properties though, just put it inside 
the appropriate constraint.

If however you want to full-text search doc as well as properties, it is 
easiest to use cts: properties-fragment-query together with search:resolve:

let $terms := “abc”
return
search:resolve(cts:and-query(($terms, cts:properties-fragment-query($terms))), 
<options…>)

In case you consider using REST api for searching, you can also express the 
properties-fragment-query in a structured query..

Cheers,
Geert

From: 
<[email protected]<mailto:[email protected]>>
 on behalf of "Fox, David" <[email protected]<mailto:[email protected]>>
Reply-To: MarkLogic Developer Discussion 
<[email protected]<mailto:[email protected]>>
Date: Monday, November 14, 2016 at 7:50 PM
To: "[email protected]<mailto:[email protected]>" 
<[email protected]<mailto:[email protected]>>
Subject: [MarkLogic Dev General] Range indexes of document properties

Hello,

I am working with a database of text documents. I have extracted some 
structured metadata from these documents and added these values as document 
properties, e.g.:

<prop:propertiesxmlns:prop="http://marklogic.com/xdmp/property";>
    <deliverytime>2011-07-06T12:45:55.7887784</deliverytime>
</prop:properties>

I wanted to add an element range index for this property, which the 
documentation says is possible even for document properties. So, via the admin 
interface I created an element range index:

[cid:[email protected]]

I then went back to the Configure view for my database and selected ‘Reindex.’

Now I would like to confirm that the range index is working, so I tried a few 
different CTS expressions:

A cts:properties-query:

cts:search(doc(), cts:properties-query(
      cts:element-range-query(xs:QName("deliverytime"), "<=",
     xs:date("2011-01-01"))
      ))

An element range query, with xdmp:document-properties() as the expression:

cts:search(xdmp:document-properties(),
      cts:element-range-query(xs:QName("deliverytime"), "<=",
      xs:date("2011-01-01"))
      )

An element range query, with doc() as the expression:

cts:search(doc(),
      cts:element-range-query(xs:QName("deliverytime"), "<=",
     xs:date("2011-01-01")
      ))

It doesn’t seem to matter which I try, they all return an error indicating:

No date element range index for deliverytime

Any idea what  I might have missed?

Also, a bonus question:

How might I combine a free text search (against the contents of my text 
documents) with a document properties query like the above, expressed as a 
search:search function?

Thank you,
David


_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to