Peter -

I'll try a quick 2 minute suggestion, then if it's not what you're
wanting, we can go from there.

1) I assume you're using simple something like:  cts:search(//fred:body,
"text")
2) there are a bunch of things we call cts:query() constructors that can
be used to assemble complex search expressions for cts:search.  There's
an API page in the online docs dedicated to them.  Cts:query
constructors go in the second parameter.
3) perhaps what you want is something more like:
cts:search(/some-higher-level-element-like-the-document-root,
cts:and-query((cts:element-query(xs:QName("fred:body"), "text"),
cts:element-query(xs:Qname("fred:title", "text")))))

Now, full warnings:
- this is a basic start.  Docs with text that occurs in both body and
title will score higher than if they just appear in title.  But scoring
is complicated and yes, you could have have docs in which the text only
occurs in body, but does so so densely that it outscores something else.
- each constructor query can be weighted (optional arg) to increase its
contribution - see the docs
- I can't remember if xs:Qname("fred:body") will work or if you have to
specify the namespace separately and explicitly - this may need a little
noodling
- there's lots of different ways to specify something like this and they
are subtly different - element-word-query vs. element-query.  A lot
depends on the indexing your using and your exact requirements.
Assumign you have positions enabled, I'm guessing that element-query is
the best start.

If you already know all this and you're asking a more complex question
(one that I can imagine), let us know.  But it figured I'd take a shot
at the simple one first.

Cheers
ian

-----Original Message-----
From: [EMAIL PROTECTED]
[mailto:[EMAIL PROTECTED] On Behalf Of Peter
Hickman
Sent: Friday, April 20, 2007 6:56 AM
To: [email protected]
Subject: [MarkLogic Dev General] Weighting search results

I apologise for what might be a completely boneheaded question.We are
wanting to do a search for some text in, for example, fred:body. I have
obviously got that working but then the request came in "search for the
text in fred:body but give it a higher score if it is also in fred:title
(which is not inside fred:body)". Anyone have any idea how we might go
about this using cts:search or are we looking at having to post process
the results of searching in fred:body?

--
Peter Hickman.

Semantico, Lees House, 21-23 Dyke Road, Brighton BN1 3FE
t: 01273 722222
f: 01273 723232
e: [EMAIL PROTECTED]
w: www.semantico.com

_______________________________________________
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