You can put weights on the cts:query constructors to affect how much a match in 
each constructor contributes to score.  You can also change the word query 
configuration on the database to boost the weight for a particular element 
(like title, for example).  The word query configuration change bakes that 
weight into the index.

To accomplish the cts:query weight boost, you might create a query that 
combines word-query and element-word-query with an and-query of a word-query 
and an or-query (so you keep the semantics the same as just the word-query), 
with a weight on the element-word-query.  Something like:

cts:and-query((
  cts:word-query($q),
  cts:or-query((
     cts:element-word-query(xs:QName("title"), $q, (), 16) ))
  ))

This would boost the score of matches that occur in title elements. 

For more details about relevance, see "Relevance Scores: Understanding and 
Customizing" chapter in the Search Developer's Guide.

-Danny

-----Original Message-----
From: [email protected] 
[mailto:[email protected]] On Behalf Of Shah, Mehul 
(LNG-NPV)
Sent: Wednesday, October 06, 2010 9:24 AM
To: General Mark Logic Developer Discussion
Subject: [MarkLogic Dev General] relevance by element/attribute values

For a given query, is there a way to indicate field1 (title) has higher weight 
compared to other fields (body-text) for search relevance.
i.e.  
Query: "New York"
Doc1- has "New York" in <bodytext> 3 times 
Doc2- has "New York" in <title> once
(where <bodytext> or <title> may have more elements within it.)

How do I do search:search to get result in such order that Doc-2 appears first 
(even though it has less hits for the query terms).


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

Reply via email to