Two things:

(1) A lot depends on what your index settings are. You should always check the 
plan: xdmp:plan(cts:search(...)) You should see something like:

  <qry:final-plan>
    <qry:and-query>
      <qry:or-two-queries synonym="true">
    <qry:term-query weight="1">
      <qry:key>10071940103343762009</qry:key>
      <qry:annotation>element(name1,word("tom"))</qry:annotation>
    </qry:term-query>
    <qry:term-query weight="1">
      <qry:key>10071940126384762201</qry:key>
      <qry:annotation>element(name2,word("tom"))</qry:annotation>
    </qry:term-query>
      </qry:or-two-queries>
    </qry:and-query>
  </qry:final-plan>

(2) Synonym scoring isn't a max, it is a term-list combiner.  So it is if those 
two terms (keys 1007...009 and 1007...201 above) are (or should be!) treated as 
if they were on the same term list for scoring purposes. For logTF or logTFIDF 
the term frequency will still matter.  score-simple ought to do what you want, 
so it looks like there is bug in how simple-scoring is handling synonym scoring 
in the context of an or like this. I have logged that bug.

Cheers

//Mary

On 08/17/2017 06:55 AM, Andreas Hubmer wrote:
Hi,

We've discovered the "synonym" option of the cts:or-query and thought that it 
would solve an issue we've had for a longer time in several applications with 
several clients. But it does not work as expected. Either I am misunderstanding 
the effect of the "synonym" option or there is a bug.

The following XQuery snippet demonstrates the issue. Three documents are 
inserted into the database. All contain the word "tom", but in different 
elements.
In the search an or-query over the different elements is used. Our expectation 
was that by using the "synonym" option all results would have the same score. 
But the document with both elements name1 and name2 is scored higher than the 
other two (about 30% higher).
Why do they have different scores?
I would expect that the "synonym" option is working like a maximum function on 
the score of the subqueries.

xquery version "1.0-ml";
xdmp:document-insert("/1.xml",
  <root>
    <name1>tom</name1>
  </root>
)
,
xdmp:document-insert("/2.xml",
  <root>
    <name1>tom</name1>
    <name2>tom</name2>
  </root>
),
xdmp:document-insert("/3.xml",
  <root>
    <name2>tom</name2>
  </root>
)
;

xquery version "1.0-ml";
cts:search(/,
  cts:or-query((
      cts:element-word-query(xs:QName("name1"), "tom"),
      cts:element-word-query(xs:QName("name2"), "tom")
    ), "synonym"),
  "score-simple"
)
!
("Score: " || cts:score(.), .)

"Fast element word searches" are turned on in the database.
The scoring model (score-simple or score-logtf) does not make a difference.

It would be great if you could help me!

Cheers,
Andreas



_______________________________________________
General mailing list
[email protected]<mailto:[email protected]>
Manage your subscription at:
http://developer.marklogic.com/mailman/listinfo/general


_______________________________________________
General mailing list
[email protected]
Manage your subscription at: 
http://developer.marklogic.com/mailman/listinfo/general

Reply via email to