This content has been marked as final. Show 3 replies
Yes, you can do that all in a single contains:
The OR operator scores the higher of its two sides, so this will work in most situations. However there is an edge-case where it won't - if "X within B" scores less than half of "X within A" then the score of the second part will become just that for "X within A" (because AND scores the lower of its two sides) and therefore X within B will not add to the overall score.
SELECT * FROM foo WHERE CONTAINS( xml, '(X within A) OR ( (X within A) AND (X within B) )*2' , 1)
Will always work. ACCUM guarantees that hits on both sides always score higher than hits on one side only, and the right-hand side here subsumes the left-hand side.
SELECT * FROM foo WHERE CONTAINS( xml, '(X within A) ACCUM ( (X within A) AND (X within B) )' , 1)
As an aside - the syntax as you have it would NOT work, as you have the same third argument (,1) in each of your CONTAINS clauses. The third argument - which is used to correlate the SCORE(n) operator with a particular CONTAINS clause - must be unique to each CONTAINS.