Maybe:

let $term := "baseball"
let $orquery :=
cts:or-query((
  cts:word-query($term, (), 1),
  cts:element-word-query(
    (xs:QName("title"), xs:QName("head")), $term, (), 16
  )
))
let $elattquery :=
cts:element-attribute-value-query(xs:QName("myElement"),
  xs:QName("type"), $term, (), 16 )
return
cts:or-query(($orquery, cts:and-query(($orquery, $elattquery)) ))

Also see Mike's reply for a more elegant and robust solution.

-Danny

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Mattio
Valentino
Sent: Thursday, April 10, 2008 1:22 PM
To: General Mark Logic Developer Discussion
Subject: Re: [MarkLogic Dev General] Boosting scores based on an
attribute

The latter is definitely true.  I tried adding the
element-attribute-value-query and I ended up with a lot of results
that were type="biography" but didn't contain the term.  Any
pointers/examples for how to work Boolean logic into this would be
appreciated!

On 4/10/08, Danny Sokolsky <[EMAIL PROTECTED]> wrote:
> Perhaps you can add another query to your "or" query list looking for
> the attribute value and boosting the score.  I think this will work as
> long as you know the element in which the type attribute exists.  For
> example:
>
> cts:or-query((
>  cts:word-query("baseball", (), 1),
>  cts:element-word-query(
>    (xs:QName("title"), xs:QName("head")), "baseball", (), 16
>  ),
>  cts:element-attribute-value-query(xs:QName("myElement"),
> xs:QName("type"),
>            "baseball", (), 16 )
> ))
>
> If you have some content that does not match your other queries but
does
> match the e-a-v-query, then you would have to make some more
complicated
> boolean logic for this to work, but that is probably doable.
>
> -Danny
>
> -----Original Message-----
> From: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] On Behalf Of Mattio
> Valentino
> Sent: Thursday, April 10, 2008 1:00 PM
> To: General Mark Logic Developer Discussion
> Subject: [MarkLogic Dev General] Boosting scores based on an attribute
>
> I'm not sure if I'm going to express this correctly but I hope it's
> clear.
>
> I have a query that searches for a term.  If the term occurs in a
> title or head element, the score is boosted.
>
> cts:or-query((
>  cts:word-query("baseball", (), 1),
>  cts:element-word-query(
>    (xs:QName("title"), xs:QName("head")), "baseball", (), 16
>  )
> ))
>
> If I have two documents where one has an attribute type="biography",
> can I form the query to return *both* documents but boost the score up
> further on the "biography" one?
>
> This has been stewing for a few days now and I've been trying
> different versions in cq, but I can't see how to put the cts:query
> constructors together to do it.
>
> Thanks for any help,
> Matt
> _______________________________________________
> 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
_______________________________________________
General mailing list
[email protected]
http://xqzone.com/mailman/listinfo/general

Reply via email to