Fields are on my list, and I definitely see the need for a query to
generate the query here. ;-)
This worked perfectly! The number of results returned is the same but
the scoring has changed as expected. I'm still processing how the
query works, but I think I follow what's going on here. The good
thing is that I have a similar but different requirement and I should
be able to apply this pattern to it as well.
Thanks!
On 4/10/08, Michael Blakeley <[EMAIL PROTECTED]> wrote:
> Mattio,
>
> Not sure if it helps, but you could consider permanently boosting the
> quality of biographies, via xdmp:set-document-quality() or a related
> function.
>
> If I understand what you're trying to do correctly, you could also make your
> query test for a matrix of possibilities at runtime. You didn't say what the
> element name is for your type attribute, but let's say it's 'document'.
>
> let $user-query := 'baseball'
> let $query := cts:or-query((
> let $booster := cts:element-attribute-value-query(
> xs:QName('document'), xs:QName('type'), 'biography'
> )
> for $i in (
> $user-query,
> cts:element-word-query(xs:QName('title'), $user-query,
> (), 16)
> )
> return (
> $i,
> cts:and-query(($booster, $i))
> )
> ))
> return $query
>
> =>
> cts:or-query((
> cts:word-query("baseball", ("lang=en"), 1),
> cts:and-query((
> cts:element-attribute-value-query(
> xs:QName("document"), xs:QName("type"), "biography",
> ("lang=en"), 1
> ),
> cts:word-query("baseball", ("lang=en"), 1)
> ), ()),
> cts:element-word-query(
> xs:QName("title"), "baseball", ("lang=en"), 16),
> cts:and-query((
> cts:element-attribute-value-query(
> xs:QName("document"), xs:QName("type"), "biography",
> ("lang=en"), 1
> ),
> cts:element-word-query(
> xs:QName("title"), "baseball", ("lang=en"), 16)
> ), ())
> ))
>
> You can probably see why I wrote a query to generate that query :-).
>
> Note that I didn't actually boost the score for the biography matches:
> they'll be boosted by TF/IDF naturally, as will the title matches (assuming
> title matches are less frequent, in TF/IDF terms, than word-query matches
> are). Very often, there isn't much reason to explicitly boost query terms.
>
> You might also think about creating a field for this query, if it's a
> frequently-used search strategy for your application.
>
> -- Mike
>
> Mattio Valentino wrote:
> >
> > 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