jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jakub Pawlowicz <cont...@jakubpawlowicz.com>
Subject Re: Searching by date (another problem)
Date Tue, 23 Aug 2005 10:26:57 GMT
Hi Marcel,

I've tested the xpath queries you've posted yesterday, and I've  
noticed that they behave differently.
When I use the first one, with the explicit calls to the xs:dateTime  
function, eg:
//*[@myDateProperty >= xs:dateTime('2005-01-01T00:00:00.000TZ') and  
@myDateProperty <= xs:dateTime('2005-12-31T23:59:59.999TZ')]
everything works perfectly well.
But when I use the short version without xs:dateTime function, eg:
//*[@myDateProperty >= '2005-01-01T00:00:00.000TZ' and  
@myDateProperty <= '2005-12-31T23:59:59.999TZ']
the result set is always empty.

What's more, when I use a single "greater" or "greater than"  
condition, eg:
//*[@myDateProperty >= '2005-01-01T00:00:00.000TZ']
the result set is always full, but when I use a single "less" or  
"less than" condition, eg:
//*[@myDateProperty <= '2005-12-31T23:59:59.999TZ']
the result set is always empty, no matter what stands on the right  
side of the relation.

It seems that the query without xs:dateTime function does not work  
Is this a bug or am I missing something?

On Aug 22, 2005, at 10:11 AM, Marcel Reutegger wrote:

> Hi Jakub,
> JSR-170 specifies a type mapping from property types to types known  
> in XPath. The relevant section in the spec is:
> regarding your queries:
> > "//*[jcr:contains(@myDateProperty, '2005')]"
> jcr:contains relies on the fulltext index, which is only required  
> by jsr-170 on a per node basis. still, jackrabbit supports fulltext  
> queries with a property scope. the reason why the above query does  
> not return results is, that jackrabbit does not fulltext index date  
> properties. and I think it is ok, that jackrabbit doesn't do that.  
> your query would be certainly convenient to find all dates of the  
> year 2005, but that's probably the only useful use case. when it  
> comes to month and day a fulltext index would be unable to  
> distinguish them. both are just two digit numbers.
> > "//*[jcr:like(@myDateProperty, '2005-%')]"
> this query does not return nodes because jcr:like only works on  
> string properties and @myDateProperty is of type date.
> what will work is the following:
> //*[@myDateProperty >= xs:dateTime('2005-01-01T00:00:00.000TZ') and  
> @myDateProperty <= xs:dateTime('2005-12-31T23:59:59.999TZ')]
> you may also omit the xs:dateTime functions because jackrabbit does  
> some basic value coercing, which includes string to date conversion:
> //*[@myDateProperty >= '2005-01-01T00:00:00.000TZ' and  
> @myDateProperty <= '2005-12-31T23:59:59.999TZ']
> regards
>  marcel
> contact@jakubpawlowicz.com wrote:
>> Hi!
>> I've been playing with Jackrabbit for some time and I'm having   
>> problems with searching by properties with a date value   
>> (java.util.Calendar).
>> I'm trying to define a constraint to find only the nodes, let's  
>> say  from the year 2005.
>> So I'm trying to perform XPath queries like
>> "//*[jcr:contains(@myDateProperty, '2005')]" or
>> "//*[jcr:like(@myDateProperty, '2005-%')]"
>> But that doesn't work - each time a set of found nodes is empty.
>> Does anyone know how to perform that kind of searching?
>> Any help would be highly appreciated.
>> Best regards
>> Jakub

View raw message