jackrabbit-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From thomasg <thomasgascoi...@hotmail.com>
Subject Xpath query question
Date Mon, 24 Apr 2006 14:30:36 GMT

Hi,

I'm having a bit of trouble with xpath queries. I'm adding nodes and set
several properties on each node for title, subject, keywords etc. I then
need to be able to search for text contained in any of the properties (a
basic OR type query).

An example of the code is:

Node node = root.addNode("thomastest", "nt:unstructured");
workspace.getNamespaceRegistry().registerNamespace("axxia", 
"http://www.axxia.com/axxia/1.0"); 
	    
node.setProperty("axxia:title", "The history of London buses");
node.setProperty("axxia:subject", "History of London Transport");
node.setProperty("axxia:keywords", "buses London history");

Executing a query such as "//*[jcr:contains(@axxia:subject, 'nonsense')]"
works fine giving a hit or no hit when changing to a word not in the
property.

This AND query behaves as expected:
"//*[jcr:contains(@axxia:title, 'history')] AND
[jcr:contains(@axxia:subject, 'history')] AND [jcr:contains(@axxia:keywords,
'history')]"
Returns a hit as above, changing 'history' to 'design' in each clause in
turn causes all to return no hits


Running the abaove query with ORs replcing the ANDs I would expect to get a
hit if any one of the clauses contains the word 'history'.
However this query seems to work like the AND above and only returns a hit
if all 3 clauses contain 'history'.
"//*[jcr:contains(@axxia:title, 'history')] OR [jcr:contains(@axxia:subject,
'history')] OR [jcr:contains(@axxia:keywords, 'history')]"

I'm new to xpath so probably doing it wrong, is there a better way to check
whether multiple properties contain a particular word(s)?

Thanks, Thomas
--
View this message in context: http://www.nabble.com/Xpath-query-question-t1499615.html#a4064776
Sent from the Jackrabbit - Dev forum at Nabble.com.


Mime
View raw message