[MarkLogic Dev General] Excluding elements from search

Danny Sokolsky dsokolsky at marklogic.com
Mon Jun 18 15:30:51 PDT 2007

Hi Peter,

Yes, Fields (new in 3.2) are a good way to get the behavior you
describe. You can create a field and include the element "document" and
exclude the element "authors".  This will include everything under
documents until it gets to a descendant that is in the excluded list
("authors" in your case).  If it then encounters another included
descendant, it will include that until it finds an excluded one.

Then you can query the field with cts:field-word-query.  

The Administrator's Guide has a chapter (Chapter 10, Fields Database
Settings) describing how to create a field and how the include/exclude
logic works. 

Hope that helps,

-----Original Message-----
From: general-bounces at developer.marklogic.com
[mailto:general-bounces at developer.marklogic.com] On Behalf Of Peter
Sent: Monday, June 18, 2007 5:27 AM
To: MarkLogic ML
Subject: [MarkLogic Dev General] Excluding elements from search

I have a document structure that is rooted in, for example, <document> 
which has somewhere in it an <authors> element.

Sometimes I want to search <document> and all its descendants, this I 
can do without any problems in MarkLogic.

However sometimes I want to search <document> and all its descendants 
but exclude <authors> and it's descendants. For the life of me I can't 
work out how to phrase this.

Does anyone have any ideas (that doesn't involve changing the structure 
of the document) how this might be achieved with MarkLogic. I am led to 
understand that the 'fields' feature of 3.2 might be of some use here 
but again am unsure as to how this might be used.


Peter Hickman.

Semantico, Lees House, 21-23 Dyke Road, Brighton BN1 3FE
t: 01273 358223
f: 01273 723232
e: peter.hickman at semantico.com
w: www.semantico.com

General mailing list
General at developer.marklogic.com

More information about the General mailing list