Db2 Text Search RESULTLIMIT function
Multiple instances of RESULTLIMIT within a query require the same search argument to produce predictable results.
Description
If you use multiple text searches that specify RESULTLIMIT in the same query, use the same search argument. Using different text search arguments might not return the expected results.
For example, in the following
query, it is unpredictable whether the 10 documents specified by RESULTLIMIT will be returned:
SELECT EMPNO
FROM EMP_RESUME WHERE RESUME_FORMAT = 'ascii'
AND CONTAINS(RESUME, '"ruby on rails"', 'RESULTLIMIT=10') = 1
AND CONTAINS(RESUME, '"java script"', 'RESULTLIMIT=10') = 1
Instead, use RESULTLIMIT as follows: SELECT EMPNO
FROM EMP_RESUME WHERE RESUME_FORMAT = 'ascii'
AND CONTAINS(RESUME, '"java script" "ruby on rails"', 'RESULTLIMIT=10') = 1
Note that this method works only when both CONTAINS functions are operating on the same table column. If they are not operating on the same column, try using FETCH FIRST n ROWS to improve query performance.