It appears as if the WHERE clause in the second select statement was causing the issue. I changed this:
WHERE LENGTH(raw) - LENGTH(REPLACE(raw,'".$term."',''))>0 AND raw LIKE '%".$term."%' COLLATE utf8_general_ci ORDER BY occur DESC
To this:
WHERE raw LIKE '%".$term."%' ORDER BY occur DESC
It appears to match all results now. The initial query filters matches from the second query. It looks like the WHERE condition of LENGTH(raw) - LENGTH(REPLACE(raw,'".$term."',''))>0
was causing the issue as well as the setting of the collation.