I have a MySQL database and i want to search using match.
I use the following query for one phrase.
SELECT
text, date, type
FROM
`test`
WHERE
MATCH (`TEXT`) AGAINST ('+word1 +word2' IN BOOLEAN MODE)
;
But i cant find a way to search '+word1 +word2' OR '+word3 +word4'
Any idea?
This is the solution:
MATCH (`TEXT`) AGAINST ('(+word1 +word2) (+word3 +word4)' IN BOOLEAN MODE)
Related
I am creating a search service using mysql's fulltext-index.
I use it by setting innodb_ft_min_token_size = 1. (Support 1 character search)
The reason for the change from ngram is that ngram=1 takes too much load because there is a lot of data.
Here's a question.
If the name is 'ABCDEF' and the search keyword is 'ABC'
SELECT * FROM SEARCH_TABLE WHERE MATCH(NAME) AGAINST('+*ABC*' IN BOOLEAN MODE);
The above query finds 'ABCDEF' normally.
SELECT * FROM SEARCH_TABLE WHERE MATCH(NAME) AGAINST('+*ABC* +*DEF*' IN BOOLEAN MODE);
But this query doesn't find 'ABCDEF'.
What could be the reason and how can I fix this?
The MySQL version is 5.1.40
The table is MyISAM(only changed the table to MyISAM)
The type of table_column(name) is varchar
When I apply the fullText search, it doesn't work.
Below sql only return data 'eeee', will not return such as 'eeeefff' or 'ffeeee'
select name from test where match(name) against('eeee' in boolean mode);
MySQL's full text search lets you search for keywords beginning, but not ending, in a certain substring. So, to find all words beginning with eeee we can try:
SELECT name
FROM test
WHERE MATCH(name) AGAINST('eeee*' IN BOOLEAN MODE);
I have a table with a fulltext on one column "volltext" type is mediumtext. The fulltext index is "volltext". I matched words on it like
SELECT * FROM `volltextsuche` WHERE MATCH(volltext) AGAINST('+search' IN BOOLEAN MODE)
this will find any occurence correctly.
BUT never for more (no matter how often it is in the text).
SELECT * FROM `volltextsuche` WHERE MATCH(volltext) AGAINST('+more' IN BOOLEAN MODE)
Text example: "more Gil Coste Corbo More
Fragile Ästhetik"
Wrapping the word with `` does not help.
SELECT * FROM `volltextsuche` WHERE MATCH(volltext) AGAINST('+`more`' IN BOOLEAN MODE)
What is this for a remarkable behaviour?
more is a stopword of fulltext search at mysql
http://dev.mysql.com/doc/refman/5.1/en/fulltext-stopwords.html
I have the following MySQL query:
SELECT title, description
FROM some_table
WHERE MATCH (title,description) AGAINST ('+denver (REGEXP "[[:<:]]colorado[s]*[[:>:]]")' IN BOOLEAN MODE);
the "regexp" here looks for a "complete word" colorado (with or without the ending "s").
I want to actually select only those rows that have ("denver") AND ("colorado" or "colorados"). But I cannot put a "+" for the REGEXP. I tried but got 0 results, although there are rows in the table that match the requirement.
Any ideas on how I can get the "+" to work within against using a REGEXP?
I am constructing this from within a PHP script where "denver" and "colorado" are values of variables I use to construct the select statement.
My PHP/MySQL script would look somewhat like this:
SELECT title, description
FROM some_table
WHERE MATCH (title,description) AGAINST ('+$var1 (REGEXP "[[:<:]]$var2[s]*[[:>:]]")' IN BOOLEAN MODE);
I don't think it's possible to combine regular expressions and MATCH ... IN BOOLEAN MODE. You need to use the syntax for writing boolean expressions.
Boolean Full-Text Searches
Try something like this:
SELECT title, description
FROM some_table
WHERE MATCH (title,description)
AGAINST ('+denver +(colorado colorados)' IN BOOLEAN MODE);
I've heared alot of similar discussion but I havent seen a direct solution.
SELECT * FROM patient_db WHERE
MATCH ( Name, id_number ) AGAINST ('%$term%' IN BOOLEAN MODE);
Isn't there something simple around my '%$term%' I need to do to enable multiple-word searching?
Unfortunately, there is no way to directly say, "I want one of these n words" in a MySQL fulltext query. Your only real option is
SELECT * FROM patient_db WHERE
MATCH ( Name, id_number ) AGAINST ('%$term%' IN BOOLEAN MODE)
OR MATCH ( Name, id_number ) AGAINST ('%$term2%' IN BOOLEAN MODE)
OR MATCH ( Name, id_number ) AGAINST ('%$term3%' IN BOOLEAN MODE)
;
Just curious, but why are you searching a column named id_number for text?