I’m searching a fairly large article database using full text search in mysql and am trying to work through how this all works out with quoted strings.
Basically when I search for ‘ “john smith” arrest ‘ I want it to return articles that have “John Smith” and “arrest” in them but not stories that only have “John” and “arrest” and definitely not stories that only have “arrest”
It appears that full text search doesn’t respect the quotes in the string AND the other terms at the same time.
I’ve tried:
MATCH(headline,byline,body,keywords)
AGAINST('"John Smith" arrest' IN BOOLEAN MODE)
and
MATCH(headline,byline,body,keywords)
AGAINST('"John Smith" + arrest' IN BOOLEAN MODE)
Would it be ok to just do something like this?
MATCH(headline,byline,body,keywords)
AGAINST('John + Smith + arrest' IN BOOLEAN MODE)
That might work out ok, but wouldn’t be completely accurate.
Thanks for the help.
By default, full text searches combine terms using OR. This means, in your first example, you are searching for rows with the word ‘arrest’ OR the phrase ‘John Smith’. To require the returned rows to have both terms, use the plus operator: