Khasm08
Khasm08

Reputation: 236

Is it possible to perform a fulltext index search in boolean mode and with query expansion?

I'm am wondering if it is even possible (say through a nested sql query) to perform WITH QUERY EXPANSION on results from a FULLTEXT INDEX search run with IN BOOLEAN MODE.

This doesn't work, but maybe it will help explain what I am looking for:

SELECT * FROM (SELECT * FROM indexed_table AS x WHERE MATCH(x.ind_col) 
AGAINST('(+word1 +word2 +word3) (+word1 +word4) (+word2 +word4)' IN BOOLEAN MODE))x 
WHERE MATCH(ind_col) AGAINST('word1 word2' WITH QUERY EXPANSION);

To clarify: I'm trying to to use the second MATCH..AGAINST ("WITH QUERY EXPANSION") on the results of the first MATCH..AGAINST ("IN BOOLEAN MODE").

Upvotes: 4

Views: 1192

Answers (2)

darkflux
darkflux

Reputation: 103

You should be able to do this with the following:

SELECT * FROM (
    SELECT * FROM `indexed_table` WHERE MATCH(ind_col) against ('(+word1 +word2 +word3) (+word1 +word4) (+word2 +word4)' IN BOOLEAN MODE)
) AS x WHERE MATCH(ind_col) against ('word1 word2' WITH QUERY EXPANSION)

Upvotes: 0

Ike Walker
Ike Walker

Reputation: 65587

You can certainly use multiple MATCH statements in a single WHERE clause and just AND them together if that satisfies your requirements.

Do this work for you?

SELECT * 
FROM indexed_table 
WHERE MATCH(ind_col) AGAINST('(+word1 +word2 +word3) (+word1 +word4) (+word2 +word4)' IN BOOLEAN MODE)
AND MATCH(ind_col) AGAINST('word1 word2' WITH QUERY EXPANSION);

Upvotes: 1

Related Questions