Yes that's pretty much what I was looking for - a couple of my co-workers
also pointed out the same thing to me.

Thanks!

-Mike

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Danny Sokolsky
Sent: Thursday, September 13, 2007 5:25 PM
To: General Mark Logic Developer Discussion
Subject: RE: [MarkLogic Dev General] querying multiple words w/AND semantics


Hi Mike,

cts:element-attribute-word query and cts:field query are leaf-level
constructors, just like cts:word-query.  You can use the composable
constructors like cts:and-query to combine these leaf-level constructors.
So I believe you can achieve what you need by using something like this:

cts:and-query((
  cts:element-attribute-word-query(xs:QName("elementname"), 
       xs:QName("attrributeName"), "word1"),
  cts:element-attribute-word-query(xs:QName("elementname"), 
       xs:QName("attrributeName"), "word2")
 ))

Depending on your content and on what you are searching over, you might find
some cases where this returns nodes where both matches are not in the same
attribute(for example, if there is one attribute with only "word1" and one
with only "word2" under the path you are searching). You should be able to
deal with that by wrapping the cts:and-query in a cts:element-query.  For
example:

cts:element-query( xs:QName("elementname"),
  cts:and-query((
    cts:element-attribute-word-query(xs:QName("elementname"), 
       xs:QName("attrributeName"), "word1"),
    cts:element-attribute-word-query(xs:QName("elementname"), 
       xs:QName("attrributeName"), "word2")
 )) )

You can compose this queries in arbitrarily complex ways to solve most of
these situations.  Does this approach do what you need?

-Danny



-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mike Sokolov
Sent: Thursday, September 13, 2007 7:00 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] querying multiple words w/AND semantics


(sorry if this came through multiple times - I had some trouble sending 
from a different address)

It seems to me there's an odd asymmetry in the cts:query constructors.

You can write a query that finds documents containing some element that
matches all of a set of words (for example, where the title contains all

the
words in a query) using
cts:element-query(cts:and-query(($words))

but there is no analogous behavior for attributes or fields (eg no
cts:field-query or cts:attribute-query taking a query as an argument).

You can specify multiple words as arguments to field-query and
attribute-word-query (and element-word-query), but these all have OR
semantics, and in my case I'm interested in AND.

Does this reflect some deeper structure in Mark Logic or is it just a 
gap in
the API?
_______________________________________________
General mailing list
[email protected] http://xqzone.com/mailman/listinfo/general
_______________________________________________
General mailing list
[email protected] http://xqzone.com/mailman/listinfo/general

_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to