You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@jackrabbit.apache.org by KÖLL Claus <C....@TIROL.GV.AT> on 2007/04/04 17:28:54 UTC

Strange behaviour between sql and xpath search

i have added a text file to my workspace and i would search it by its name with the contains function
With the sql search it will be found

SELECT * FROM nt:base WHERE contains(*, '*.txt')

If i try to search with XPath i didnt find it !

//element(*, nt:base)[jcr:contains(*, '*.txt')]

I think the two statements are the same or not ?

With xpath i do only find strings with contains(*) on the jcr:content node !
Is this a bug ??

My node structure looks like:

/test.txt (nt:file)
-my:name (Mixin)
 - .. some Mixin properties
 /jcr:content (nt:resource)
   -jcr:mimetype
   -jcr:lastModified
   -jcr:data

thanks for any help
claus


Re: AW: AW: Strange behaviour between sql and xpath search

Posted by Marcel Reutegger <ma...@gmx.net>.
KÖLL Claus wrote:
> the tool is great !
> i think we should post it on the wiki site .. what do you think ..

sure, go ahead...

regards
  marcel

AW: AW: Strange behaviour between sql and xpath search

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
hi marcel,

the tool is great !
i think we should post it on the wiki site .. what do you think ..

thanks
claus

-----Ursprüngliche Nachricht-----
Von: Marcel Reutegger [mailto:marcel.reutegger@gmx.net] 
Gesendet: Dienstag, 10. April 2007 12:19
An: users@jackrabbit.apache.org
Betreff: Re: AW: Strange behaviour between sql and xpath search

KÖLL Claus wrote:
> found my own failure ;-)
> the scope in xpath must be "." not "*"
> 
> //element(*, nt:base)[jcr:contains(., '*.txt')] works now

and here's the reason why: * matches all child nodes of the context node, while 
. matches the context node itself.

there's a little tool online that maps SQL to XPath and vice versa. you can even 
see the jackrabbit internal representation of the query:

http://people.apache.org/~mreutegg/jcr-query-translator/translator.html

regards
  marcel

Re: AW: Strange behaviour between sql and xpath search

Posted by Marcel Reutegger <ma...@gmx.net>.
KÖLL Claus wrote:
> found my own failure ;-)
> the scope in xpath must be "." not "*"
> 
> //element(*, nt:base)[jcr:contains(., '*.txt')] works now

and here's the reason why: * matches all child nodes of the context node, while 
. matches the context node itself.

there's a little tool online that maps SQL to XPath and vice versa. you can even 
see the jackrabbit internal representation of the query:

http://people.apache.org/~mreutegg/jcr-query-translator/translator.html

regards
  marcel

AW: Strange behaviour between sql and xpath search

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
found my own failure ;-)
the scope in xpath must be "." not "*"

//element(*, nt:base)[jcr:contains(., '*.txt')] works now

BR,
claus

-----Ursprüngliche Nachricht-----
Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT] 
Gesendet: Donnerstag, 05. April 2007 07:10
An: users@jackrabbit.apache.org
Betreff: AW: Strange behaviour between sql and xpath search

hi brian,
thank you for the hint,
but i want to find the name through the fulltext search ..
the users are searching in the fulltext and should also be able to find a document not only by its content
but also with its name so *.txt is a valid search in my case

claus

-----Ursprüngliche Nachricht-----
Von: Brian Thompson [mailto:elephantium@gmail.com] 
Gesendet: Donnerstag, 05. April 2007 01:52
An: users@jackrabbit.apache.org
Betreff: Re: Strange behaviour between sql and xpath search

Try

SELECT * FROM nt:base WHERE my:name = 'test.txt'

or something like

SELECT * FROM nt:base WHERE contains(my:name, '%.txt')

-Brian


On 4/4/07, KÖLL Claus <C....@tirol.gv.at> wrote:
>
> yet another information,
>
> the "test.txt" string is in the my:name property .
> the file node name itself is something like "hgugh2374jbbjk.txt"
>
> claus
> -----Ursprüngliche Nachricht-----
> Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
> Gesendet: Mittwoch, 04. April 2007 17:29
> An: users@jackrabbit.apache.org
> Betreff: Strange behaviour between sql and xpath search
>
> i have added a text file to my workspace and i would search it by its name
> with the contains function
> With the sql search it will be found
>
> SELECT * FROM nt:base WHERE contains(*, '*.txt')
>
> If i try to search with XPath i didnt find it !
>
> //element(*, nt:base)[jcr:contains(*, '*.txt')]
>
> I think the two statements are the same or not ?
>
> With xpath i do only find strings with contains(*) on the jcr:content node
> !
> Is this a bug ??
>
> My node structure looks like:
>
> /test.txt (nt:file)
> -my:name (Mixin)
> - .. some Mixin properties
> /jcr:content (nt:resource)
>    -jcr:mimetype
>    -jcr:lastModified
>    -jcr:data
>
> thanks for any help
> claus
>
>

AW: Strange behaviour between sql and xpath search

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
hi brian,
thank you for the hint,
but i want to find the name through the fulltext search ..
the users are searching in the fulltext and should also be able to find a document not only by its content
but also with its name so *.txt is a valid search in my case

claus

-----Ursprüngliche Nachricht-----
Von: Brian Thompson [mailto:elephantium@gmail.com] 
Gesendet: Donnerstag, 05. April 2007 01:52
An: users@jackrabbit.apache.org
Betreff: Re: Strange behaviour between sql and xpath search

Try

SELECT * FROM nt:base WHERE my:name = 'test.txt'

or something like

SELECT * FROM nt:base WHERE contains(my:name, '%.txt')

-Brian


On 4/4/07, KÖLL Claus <C....@tirol.gv.at> wrote:
>
> yet another information,
>
> the "test.txt" string is in the my:name property .
> the file node name itself is something like "hgugh2374jbbjk.txt"
>
> claus
> -----Ursprüngliche Nachricht-----
> Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
> Gesendet: Mittwoch, 04. April 2007 17:29
> An: users@jackrabbit.apache.org
> Betreff: Strange behaviour between sql and xpath search
>
> i have added a text file to my workspace and i would search it by its name
> with the contains function
> With the sql search it will be found
>
> SELECT * FROM nt:base WHERE contains(*, '*.txt')
>
> If i try to search with XPath i didnt find it !
>
> //element(*, nt:base)[jcr:contains(*, '*.txt')]
>
> I think the two statements are the same or not ?
>
> With xpath i do only find strings with contains(*) on the jcr:content node
> !
> Is this a bug ??
>
> My node structure looks like:
>
> /test.txt (nt:file)
> -my:name (Mixin)
> - .. some Mixin properties
> /jcr:content (nt:resource)
>    -jcr:mimetype
>    -jcr:lastModified
>    -jcr:data
>
> thanks for any help
> claus
>
>

Re: Strange behaviour between sql and xpath search

Posted by Brian Thompson <el...@gmail.com>.
Try

SELECT * FROM nt:base WHERE my:name = 'test.txt'

or something like

SELECT * FROM nt:base WHERE contains(my:name, '%.txt')

-Brian


On 4/4/07, KÖLL Claus <C....@tirol.gv.at> wrote:
>
> yet another information,
>
> the "test.txt" string is in the my:name property .
> the file node name itself is something like "hgugh2374jbbjk.txt"
>
> claus
> -----Ursprüngliche Nachricht-----
> Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT]
> Gesendet: Mittwoch, 04. April 2007 17:29
> An: users@jackrabbit.apache.org
> Betreff: Strange behaviour between sql and xpath search
>
> i have added a text file to my workspace and i would search it by its name
> with the contains function
> With the sql search it will be found
>
> SELECT * FROM nt:base WHERE contains(*, '*.txt')
>
> If i try to search with XPath i didnt find it !
>
> //element(*, nt:base)[jcr:contains(*, '*.txt')]
>
> I think the two statements are the same or not ?
>
> With xpath i do only find strings with contains(*) on the jcr:content node
> !
> Is this a bug ??
>
> My node structure looks like:
>
> /test.txt (nt:file)
> -my:name (Mixin)
> - .. some Mixin properties
> /jcr:content (nt:resource)
>    -jcr:mimetype
>    -jcr:lastModified
>    -jcr:data
>
> thanks for any help
> claus
>
>

AW: Strange behaviour between sql and xpath search

Posted by KÖLL Claus <C....@TIROL.GV.AT>.
yet another information,

the "test.txt" string is in the my:name property .
the file node name itself is something like "hgugh2374jbbjk.txt"

claus
-----Ursprüngliche Nachricht-----
Von: KÖLL Claus [mailto:C.KOELL@TIROL.GV.AT] 
Gesendet: Mittwoch, 04. April 2007 17:29
An: users@jackrabbit.apache.org
Betreff: Strange behaviour between sql and xpath search

i have added a text file to my workspace and i would search it by its name with the contains function
With the sql search it will be found

SELECT * FROM nt:base WHERE contains(*, '*.txt')

If i try to search with XPath i didnt find it !

//element(*, nt:base)[jcr:contains(*, '*.txt')]

I think the two statements are the same or not ?

With xpath i do only find strings with contains(*) on the jcr:content node !
Is this a bug ??

My node structure looks like:

/test.txt (nt:file)
-my:name (Mixin)
 - .. some Mixin properties
 /jcr:content (nt:resource)
   -jcr:mimetype
   -jcr:lastModified
   -jcr:data

thanks for any help
claus