You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@jackrabbit.apache.org by olivier <ol...@voila.fr> on 2006/08/22 12:07:22 UTC
Search with the SQL language and conditions
Hi,
I would search files in the repository. I use SQL language.
Here my code :
String keywords = "olivier";
String querySQL = "SELECT * FROM " + "nt:file" +" WHERE jcr:path Like '%" + keywords + "%'";
QueryManager queryManager = session.getWorkspace().getQueryManager();
Query query = queryManager.createQuery(querySQL,"sql");
QueryResult queryResult = query.execute();
System.out.println("noombre de resultats : " + queryResult.getRows().getSize());
I obtain no error, but no results. When i delete the condition "where...", I recover all the files.
Why don't it function with the condition "where..."?
Somebody can he help me?
Olivier
Re: Search with the SQL language and conditions
Posted by Marcel Reutegger <ma...@gmx.net>.
Expressions on the pseudo property jcr:path are very limited and will
in general only work in a reasonable way when you limit the nodes to a
certain subtree of the workspace.
e.g. jcr:path like '/foo/bar/%'
XPath might do the job:
//element(oliver, nt:file)
will return all nt:file nodes named 'oliver'.
Jackrabbit also puts the node name into the fulltext index, which
means you could to this:
select * from nt:file where contains(*,'oliver')
or
//element(*, nt:file)[jcr:contains(*,'oliver')]
regards
marcel
olivier wrote:
> Hi,
> I would search files in the repository. I use SQL language.
> Here my code :
> String keywords = "olivier";
> String querySQL = "SELECT * FROM " + "nt:file" +" WHERE jcr:path Like '%" + keywords + "%'";
> QueryManager queryManager = session.getWorkspace().getQueryManager();
> Query query = queryManager.createQuery(querySQL,"sql");
> QueryResult queryResult = query.execute();
> System.out.println("noombre de resultats : " + queryResult.getRows().getSize());
> I obtain no error, but no results. When i delete the condition "where...", I recover all the files.
> Why don't it function with the condition "where..."?
> Somebody can he help me?
> Olivier