jackrabbit-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Amir Mistric" <amist...@nemours.org>
Subject RE: XPath difference in queries
Date Tue, 19 Jun 2007 01:18:34 GMT
Now that I am reading the specifications I see following for jcr:contains() function :

--- begin quote ---
At minimum, all implementations must support the simple search-engine syntax defined by exp
in the EBNF above. This syntax is based on the syntax of search engines like Google.
The semantics of the simple search expression are as follows:
• Terms separated by whitespace are implicitly ANDed together.
• Terms may also be ORed with explicit use of the OR keyword.
• AND has higher precedence than OR.
• Terms may be excluded by prefixing with a – (minus sign) character. This means that
the result set must not contain the excluded term.
• A term may be either a single word or a phrase delimited by double quotes (").
• The entire text search expression (searchexp in the EBNF, above) must be delimited by
single quotes (').
• Within the searchexp literal instances of single quote (“'”), double quote (“"”)
and hyphen (“-”) must be escaped with a backslash (“\”). Backslash itself must therefore
also be escaped, ending up as double backslash (“\\”).
--- end quote ---

Does this mean if I have a form in which user is entering search query I don't have to "build"
(tokenize, validate, reconstruct, etc, etc) the XPAth query...
I can just pass in something like

jcr:contains(.,'rock AND roll OR disco -techno') and it will work? 

Would I have to take care of the last point (escape special chars) or is that done automatically?



Thanks
 
Amir
 

> -----Original Message-----
> From: Amir Mistric [mailto:amistric@nemours.org] 
> Sent: Monday, June 18, 2007 8:47 PM
> To: users@jackrabbit.apache.org
> Subject: XPath difference in queries
> 
> Hi
> 
> I am a bit new to Xpath in Jackrabbit but can someone tell me 
> what is the difference between these 3 queries:
> 
> Q1: 
> //*[@jcr:primaryType='mgnl:content']//*[jcr:contains(.,'term1'
) and jcr:contains(., 'term2')]
> 
> Q2: //*[@jcr:primaryType='mgnl:content' and 
> jcr:contains(.,'term1') and jcr:contains(.,'term2')]
> 
> Q3: //element(*,nt:base)[@jcr:primaryType='mgnl:content' and 
> jcr:contains(.,'term1') and jcr:contains(.,'term2')]
> 
> 
> Basically all I want is to extract all the nodes of primary 
> type "mgnl:content" and then to search them for the query 
> terms which are ANDed.
> 
> 
> Any help is appreciated
> 
> Regards
> Amir
> 
Mime
View raw message