mysql fulltext search doesn't work with some keywords - mysql

i have the following query
SELECT * FROM products
LEFT JOIN product_variations ON products.id=product_variations.productID
WHERE
(
MATCH(products.title, products.metatitle) AGAINST('+ضد*' IN BOOLEAN MODE) > 0 OR
MATCH(product_variations.title, product_variations.metatitle) AGAINST('+ضد*' IN BOOLEAN MODE) > 0
)
why this query doesn't find any result with ضد keyword but find some results with ضع keyword (there is one character difference)
note1: ft_min_word_len = 2
note2: there is enough results in database for both keywords

The problem might be in the character set and collation of your table, see SQL fiddle

Related

Question about fulltext index wildcard usage

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?

Using wildcards in mysql fulltext search phrase

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?

Fulltext search doesn't exclude -xxxword

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.

relevance score of MATCH..AGAINST is not working (MySql)

Relevance score of MATCH..AGAINST is not working.
Created one dummy table which has 2 rows.
Dummy Table
Row1=> 'Leela Hayat Marriot'
Row2=> 'Americas Best Value'
Query1:
SELECT MATCH (col1) AGAINST ('Leela* Hayat*' IN BOOLEAN MODE) AS relevance
FROM table1
WHERE MATCH (col1) AGAINST ('Leela* Hayat*' IN BOOLEAN MODE);
Result:
relevance
2
Query2:
SELECT MATCH (col1) AGAINST ('Americas* Best*' IN BOOLEAN MODE) AS relevance
FROM table1
WHERE MATCH (col1) AGAINST ('Americas* Best*' IN BOOLEAN MODE);
Result:
relevance
1
Query1 is working fine but why is query 2 not working?
Why am I getting relevance 1 instead of 2 in Query2 as Americas and Best both are present in column.
Thanks
http://dev.mysql.com/doc/refman/5.7/en/fulltext-stopwords.html
'BEST' is listed in stopword list.
http://dev.mysql.com/doc/refman/5.7/en/server-system-variables.html#sysvar_ft_stopword_file
ft_stopword_file:
The file from which to read the list of stopwords for full-text searches on MyISAM tables. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. All the words from the file are used; comments are not honored. By default, a built-in list of stopwords is used (as defined in the storage/myisam/ft_static.c file). Setting this variable to the empty string ('') disables stopword filtering.
I disabled stopwords list and now query 2 is working fine.
Thanks for help.

MATCH() AGAINST() not matching the second string - MySQL

I have a MyISAM table named links. It has a column searcher which has a FULLTEXT index to it.
This is my variable values:
ft_min_word_len = 1
ft_stopword_file =
ft_max_word_len = 84
I need to match the rows which contain both [show] & [1] in any order.
I run this query:
SELECT * FROM links WHERE MATCH(searcher) AGAINST('+[show] +[1]' IN BOOLEAN MODE)
But it is also matching the rows that don't contain [1] string. Whats the problem?
It seems that you have to make clear that the brackets are part of the search string and not part of syntax for grouping expressions.
This query should work for you:
SELECT * FROM links WHERE MATCH(searcher) AGAINST('+"[show]" +"[1]"' IN BOOLEAN MODE)
Here are some sample fiddles:
not working
working