jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Marcel Reutegger <marcel.reuteg...@gmx.net>
Subject Re: Struggling with search
Date Tue, 18 Mar 2008 15:46:32 GMT
Dave Brosius wrote:
> My next problem is this. I have this query:
> 
> //*[jcr:primaryType = 'prm:File' and jcr:contains(jcr:content/@jcr:data, 'sample')] order
by jcr:score() descending

see query section in jackrabbit faq: 
http://jackrabbit.apache.org/frequently-asked-questions.html

> Then i change it to
> 
> //*[jcr:primaryType = 'prm:File' and jcr:content/@jcr:data] order by jcr:score() descending
> 
> and again i get nothing, which seems completely wrong.

I quickly created a test, which works for me:

         Node file = testRootNode.addNode("test.txt", "nt:file");
         Node resource = file.addNode("jcr:content", "nt:resource");
         resource.setProperty("jcr:lastModified", Calendar.getInstance());
         resource.setProperty("jcr:mimeType", "text/plain");
         resource.setProperty("jcr:encoding", "UTF-8");
         resource.setProperty("jcr:data", "hello world", PropertyType.BINARY);
         testRootNode.save();
         String stmt = "//*[@jcr:primaryType = 'nt:file' and 
jcr:content/@jcr:data]";
         QueryResult result = executeQuery(stmt);
         for (NodeIterator it = result.getNodes(); it.hasNext(); ) {
             System.out.println(it.nextNode().getPath());
         }


this returns the previously created file.

please note the @ in @jcr:primaryType.

can you please provide some code that illustrates what you are trying to do?

regards
  marcel

Mime
View raw message