To query the value of an element, use an element-value-query term like this:

  cts:element-value-query(xs:QName('meta:DateLoaded'), '2011*')

But since that uses a wildcard glob, it won't resolve from indexes unless you 
also have appropriate wildcards enabled. If you have an element range index on 
meta:DateLoaded with type=date, it would probably be better to specify a range 
instead of a wildcard:

  cts:element-range-query(xs:QName('meta:DateLoaded'), '>=', 
xs:date('2011-01-01')),
  cts:element-range-query(xs:QName('meta:DateLoaded'), '<', 
xs:date('2012-01-01'))

Finally, it may be faster to evaluate the entire cts:query using 
xdmp:estimate(cts:search($query)) rather than count(cts:uris($query)). Using 
count() will be O(n) with the number of results. Note that both count and 
estimate support an optional limit argument, which might be useful for your '1 
to 1000000' limit.

-- Mike

On 1 Dec 2011, at 01:46 , amit gope wrote:

> Hi All,
> 
> I have a database where the element range index is on the element date, and 
> now i am executing a query where i have used element value query on one of 
> the elements, but the results fetched are not adhering to the query, please 
> suggest the changes that i need to make.
> 
> let $uri :=(cts:uris('', ('document','limit=1000000'),
>             (cts:and-query((cts:directory-query('/content/', 'infinity'),
>         cts:element-query((xs:QName('meta:DateLoaded')),'2011*'),
>         cts:element-query((xs:QName('meta:PubName')),'Springer'),
>             cts:element-query(xs:QName('Affiliation'), cts:and-query((), ())),
>         cts:element-query(xs:QName('meta:Institution'),cts:and-query((),())),
>         cts:not-query(cts:element-query(xs:QName("meta:GeoOrg"), 
> cts:and-query((), ())))
>               ), ())), (), ()))[1 to 1000000]
> return (count($uri),$uri)
> 
> 
> In the above query it is fetching me uri's of those articles where the meta 
> dateloaded is 2010. Please suggest
> 
> -- 
> Regards
> Amit 
> 
> 
> _______________________________________________
> 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