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?
Related
I'm using mysql 5.7 and am having trouble using a wildcard character in a fulltext query.
I want to use the search phase "cleft palate" and have it also include matches for the plural version "cleft palates".
The 2 queries below return the same exact results:
select *
from contents
where match(contents.content) against('+("cleft palate")' in boolean mode)
And
select *
from contents
where match(contents.content) against('+("cleft palate*")' in boolean mode)
Note the wildcard (*)
Both these query are leaving out results for "cleft palates"
Is there a way to use the wildcard character within a phrase in a fulltext query?
I am trying to make a query where I select all the rows that do not contain a specific word, for this I have a fulltext type index in this column, try the following bolt works:
SELECT *
FROM products
WHERE MATCH(title) AGAINST(' -Dolo' IN BOOLEAN MODE)
So how can I perform this search?
If I have understood you correctly you want to find all the rows from the table that do not contain a word'Dolo'.
Well you can use NOT operator for that.
SELECT *
FROM products
WHERE NOT MATCH(title) AGAINST('Dolo');
Here is a DEMO.
Also, you can use it like this(because as the OP has asked: "if the whole word is "dolorem", would this query work?"):
SELECT title as Title
, MATCH(title) AGAINST('Dolo*' IN BOOLEAN MODE) as Score
FROM products
WHERE MATCH(title) AGAINST('Dolo*' IN BOOLEAN MODE) = 0;
* is a wildcard.
Other signs are described here: https://dev.mysql.com/doc/refman/8.0/en/fulltext-boolean.html
Here is the DEMO for the second example.
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);
We use fulltext search on a french CMS ( SPIP ). The resultat of a search with a minus word doesn't seems correct. We tried the sql request generated by the CMS in phpMyAdmin :
SELECT t.id_zotspip, t.titre, t.resume,
MATCH(t.`titre`) AGAINST ('+corrosion -bacteria' IN BOOLEAN MODE) * 10
+ MATCH(t.`titre`,t.`resume`) AGAINST ('+corrosion -bacteria' IN BOOLEAN MODE) * 2.2 AS score
FROM `spip_zotero311`.spip_zitems AS t
WHERE ((MATCH(t.`titre`) AGAINST ('+corrosion -bacteria' IN BOOLEAN MODE))
OR (MATCH(t.`titre`,t.`resume`) AGAINST ('+corrosion -bacteria' IN BOOLEAN MODE)))
GROUP BY t.id_zotspip ORDER BY score DESC LIMIT 0,500
We get results with bacteria in the resume...
The type of the table is MyISAM but the type of the base is InnoDB.
Any suggestions ?
Thank you.
The problem is in OR clause inside where. You should replace OR inside WHERE clause with AND.
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);