MySql full text search 2 characters - mysql

I'm using MySQL FullText Index Search on my system and when I search with 3 characters the query works well but when I search with 2 characters the query returns null.
I use this query:
select *
from table
where MATCH (description) AGAINST ('+gp*' IN BOOLEAN MODE)
I already use this command show variables like 'ft%' to get the value of ft_min_word_len and the value is 4. It is strange that with 3 characters the query works.
However i tried to change this value on file /root/.my.cnf. (I use Ubuntu 14.04 and server pilot). I add this to the file:
[mysqld]
innodb_ft_min_token_size=2
ft_min_word_len=2
Restart the mysql, drop index and create index.
Although when I execute this command again show variables like 'ft%' the value still remains 4.
How do I use mysql full text search with 2 characters?
Any help will be appreciated!

Correct location of the my.cnf?
/etc/mysql/my.cnf
Take a look here or here

Related

Unable to access column names from information_schema (MySQL/MariaDB)

I'm trying to get column names from a specific table.
EDIT:
I forgot to mention it initially, but the python script i.e. gets the table names without any issues (different query), but the one selecting column names runs into an error.
When I write this query (see below) inside of DBeaver's SQL editor I get the expected result. But when I run the query inside of my python script, I get an error that COLUMN_NAME doesn't exist.
SELECT column_name FROM information_schema.columns WHERE table_schema=<database-name> AND table_name=<table-name>;
(db name and table name are correctly written in the real query)
I also need to mention, that when I previously used MySQL Workbench, this query written in python has worked as expected. It was when I switched to DBeaver for database management that the issue arose.
Are there possibly some further steps I need to do inside of DBeaver in order to get the information_schema to work as expected?
mysql --version >> mysql Ver 15.1 Distrib 10.4.13-MariaDB, for Linux (x86_64) using EditLine wrapper
WHERE table_schema=<database-name> AND table_name=<table-name>;
If there are no quotes around those two names, and if there is punctuation or spacing in the names, any of several error can occur.
Don't simply stick the names in; quote them and escape certain characters. Or use some "bind" technique. Show us the actual Python code that builds the string and the built SQL string.
Say this to your server
SHOW VARIABLES LIKE 'lower_case_table_names';
If you get the value 0 your table names are case sensitive. (1 means case-insensitive). See this for a bit more explanation.
If your names are case-sensitive you may need to try a query with this casing.
SELECT COLUMN_NAME FROM information_schema.COLUMNS WHERE TABLE_SCHEMA=<database-name> AND TABLE_NAME=<table-name>;
Be sure to give <database-name> and <table-name> in the case you used to create them.

Match Against no results

I have an issue with a full text search in a MySQL table.
MATCH AGAINST returns no results even I if have 7 records containing the words I'm looking for. What can I do to make it return the rows?
SELECT *
FROM site_plugin_products_cache_texts
WHERE MATCH(item_text) AGAINST ('+your +name' IN BOOLEAN MODE);
No rows.
SELECT *
FROM site_plugin_products_cache_texts
WHERE item_text LIKE'%your name%'
7 rows (0.071 s)
http://sqlfiddle.com/#!9/70c3fa/1/0
Thanks.
Both of those words are included in the Stopwords for MyISAM Search Indexes, which is essentially a list of words to completely ignore in fulltext indexing (as typically they tend to occur too frequently).
The simplest solution would be to switch to InnoDB as your engine, as it has a much shorter list of stopwords. If you need to use MyISAM, you will have to do the following:
To override the default stopword list for MyISAM tables, set the ft_stopword_file system variable. (See Section 5.1.7, “Server System Variables”.) The variable value should be the path name of the file containing the stopword list, or the empty string to disable stopword filtering. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. After changing the value of this variable or the contents of the stopword file, restart the server and rebuild your FULLTEXT indexes.

full text search not working for varchar in mysql

I have designed a myisam table for full text search purpose.
I have define full text for customer_code column. customer_code is varchar(20). It only search for "1234" and "0011" but not for "123" and "456".
My sql query is:
SELECT *
FROM tbl_customer
WHERE MATCH(tbl_customer.customer_code) AGAINST('123')
Do i have to define some more for it?
It may not work because of the word length being specified on ft_min_word_len
http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html
So in debian/ubuntu its usually /etc/mysql/my.cnf
You need to set the min length there. In your case I suppose its 4 so you need to set it less than that.
Make sure after resetting the word length to restart the mysql. In addition you may need to drop the indexes and rebuilt or repair the table.
More over there are different way you can use wild card on full text search. Check the following this might help you.
http://forums.mysql.com/read.php?107,113504,113504
In WAMP you can find the configuration file on WAMP wizard or in
\wamp\bin\mysql\mysql{version}\my.ini

MySQL Fulltext searching and minimum search term length

I am using fulltext searching in mysql to search a database of videos I have, however when I search my videos some results will never get returned because the title I am searching for is less than the ft_min_word_len set in MySQL's settings.
mysql_query("SELECT MATCH(videoDescription) AGAINST('".$searchString."' IN NATURAL LANGUAGE MODE)
FROM videos
LIMIT ".$start.",".$end."");
I tried firing up the mysql console to change the setting, however it told me it is read only. The only possible solution I have seen is to have the setting overridden at startup with option files. How do I use option files to overwrite the ft_min_word_len to 2 at startup?
ft_min_word_len is a system variable, that has to be set at the startup of the MySQL server.
This can be done passing parameters on the command-line used to start MySQL, or (recommended, I'd say), using a file containing options -- generally, for example, something like /etc/my.cnf or /etc/mysql/my.cnf should do the trick.
For more informations about setting system variables, you can take a look at the following section of the manual :
4.2.3. Specifying Program Options
Also, don't forget that you'll have to rebuild your fulltext index, after changing that parameter, so the new value is taken into account.

How can I write full search index query which will not consider any stopwords?

I have written a query which will perform Full Text search using full search Index in mysql Table.
But my problem is that when user searches with "to go" then it will not search anything because of stopwords in mysql.
So my question is, how can I write a Full Search query which will ignore the stopwords?
To override the default stopword list, set the ft_stopword_file system variable. (See Section 5.1.4, “Server System Variables”.) The variable value should be the path name of the file containing the stopword list, or the empty string to disable stopword filtering. The server looks for the file in the data directory unless an absolute path name is given to specify a different directory. After changing the value of this variable or the contents of the stopword file, restart the server and rebuild your FULLTEXT indexes.
http://dev.mysql.com/doc/refman/5.1/en/fulltext-fine-tuning.html