Hello Æde,

Searching for empty strings is kind of tricky: you can configure (hmm, not sure 
if can configure though, but I have done it before) that when a property is an 
empty string, it gets deleted. So, in that case, your idea wouldn't work 
either. Also not sure from the top of my head whether <d:literal></d:literal> 
or <d:literal>''</d:literal> should be used, and whether 'null' is the result 
of the first one....

but fortunately, there is a reason I do not know this :-)

I always avoid these kind of searches and do them otherwise, which is also 
always the strategy preferred in Lucene user lists, where every now and then 
people ask about searching for documents *not* having some field. I think it is 
a non-match with the concept of inverted indices, but this is a site track.

Anyway, the way I do this:

You have an extractor that results in this property, right? For example the 
extractor:

<instruction property="myprop" namespace="http://hippo.nl/cms/1.0"; 
xpath="/document/meta/myprop/text()"/>

Add an instruction:

<instruction property="myproplength" namespace="http://hippo.nl/cms/1.0"; 
xpath="string-length(/document/meta/myprop/text())"/>

And add to your dasl-indexer.xml that myproplength should be indexed as an 
integer, so:

<property namespace="http://hippo.nl/cms/1.0"; name="myproplength" type="int"/>

(if you add an extractor, touch (re-save) all documents in the repository. If 
there are many, use a webdav batch tool)

And now, your query is 

 <d:where>
       <d:and>
         <d:not>
           <d:is-collection/>
         </d:not>
         <d:not>
           <d:eq>
             <d:prop><h:myproplength/></d:prop>
             <d:literal>0</d:literal>
           </d:eg>
         </d:not>
       </d:and>
     </d:where>


Or if this results in also documents not having the myproplength prop (not sure 
from top of my head) you can use:


 <d:where>
       <d:and>
           <d:gt>
             <d:prop><h:myproplength/></d:prop>
             <d:literal>0</d:literal>
           </d:gt>
       </d:and>
     </d:where>

Hope this helps,

Regards Ard

> 
> Hi,
> 
> I have got a relatively simple question is should seem. The 
> repository currently contains a variety of items. I need to 
> retrieve all of them from a certain start point that have a 
> non empty string value for a property.
> 
> This is the DASL that I use but has no results:
> 
> <?xml version="1.0" encoding="utf-8" ?>
> <d:searchrequest xmlns:h="http://hippo.nl/cms/1.0"; 
> xmlns:d="DAV:" xmlns:s="http://jakarta.apache.org/slide/";>
>   <d:basicsearch>
>     <d:select>
>       <d:prop>
>         <s:nrHits/>
>         <h:myprop/>
>         <h:UID/>
>         ....
>         ....
>       </d:prop>
>     </d:select>
> 
>     <d:from>
>       <d:scope>
>         <d:href>content/documents/somedir</d:href>
>         <d:depth>Infinity</d:depth>
>       </d:scope>
>     </d:from>
> 
>     <d:where>
>       <d:and>
>         <d:not>
>           <d:is-collection/>
>         </d:not>
>         <d:not>
>           <d:eq>
>             <d:prop><h:myprop/></d:prop>
>             <d:literal></d:literal>
>           </d:eg>
>         </d:not>
>       </d:and>
>     </d:where>
>   </d:basicsearch>
> </d:searchrequest>
> 
> As I interpreted the where clause it would say get all items 
> that are not a collection and have a value other than an 
> empty string for property myprop. Is there perhaps a special 
> definition for an empty string?
> 
> Changing the were clause into:
> 
>     <d:where>
> 
>       <d:and>
> 
>         <d:not>
> 
>           <d:is-collection/>
> 
>         </d:not>
> 
>         <d:is-defined>
> 
>           <d:prop><h:myprop/></d:prop>
> 
>         </d:is-defined>
> 
>       </d:and>
> 
>     </d:where>
> 
> results in all documents including the ones with an empty 
> string for property h:myprop. So I can get get results.
> 
> Any help is appreciated!
> Æde
> 
> 
> _________________________________________________________________
> Express yourself instantly with MSN Messenger! Download today 
> it's FREE!
> http://messenger.msn.click-url.com/go/onm00200471ave/direct/01
> /********************************************
> Hippocms-dev: Hippo CMS development public mailinglist
> 
> Searchable archives can be found at:
> MarkMail: http://hippocms-dev.markmail.org
> Nabble: http://www.nabble.com/Hippo-CMS-f26633.html
> 
> 
********************************************
Hippocms-dev: Hippo CMS development public mailinglist

Searchable archives can be found at:
MarkMail: http://hippocms-dev.markmail.org
Nabble: http://www.nabble.com/Hippo-CMS-f26633.html

Reply via email to