Hi Stephen,

Did you take a look at creating a field? This allows you to build your weights 
into the index, and operates like a or-query() across the elements included in 
your field. You would then query the field with a cts:field-word-query():

http://developer.marklogic.com/pubs/4.1/apidocs/cts-query.html#cts:field-word-query

Kelly

Message: 3
Date: Tue, 4 Aug 2009 15:56:48 +0100
From: Stephen Bennett <[email protected]>
Subject: [MarkLogic Dev General] Scoring a cts:or-query()
To: [email protected]
Message-ID:
        <[email protected]>
Content-Type: text/plain; charset="iso-8859-1"

I've got documents in my MarkLogic datastore that contains address information 
in the following format:

<address>
<line>13 Some Street</line>
<line>Some District</line>
<posttown>Sometown</posttown>
<county>SomeCounty</county>
<postcode>SC1 1CS</postcode>
</address>

I want to be able to search across the full address, giving a higher weighting 
to results that match in the posttown or county elements. So I've currently got 
the following cts:or-query() set up:

cts:or-query ((
cts:element-word-query(xs:QName('line'), $searchstring, ('case-insensitive', 
'punctuation-insensitive'), 0.0), cts:element-word-query(xs:QName('posttown'), 
$searchstring, ('case-insensitive', 'punctuation-insensitive'), 16.0), 
cts:element-word-query(xs:QName('county'), $searchstring, ('case-insensitive', 
'punctuation-insensitive'), 6.0),
))

This almost works fine, however I also want the items that contain more 
instances of the search string in line, posttown and county to appear higher in 
the list of results. Currently if two or more addresses appear in the same 
posttown, they get the same score, even if the county or line also contains the 
search term for one.

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

Reply via email to