Search in forum with innodb - mysql

I'm using MySQL 5.3 and have no possiblilty to update it to a newer version (5.6 supports full-text search for innodb).
So my question is, should I user Myisam instead so I can use full-text search for my forums table?
The users need to be able to search in the table or should I solve it someway else, (what way?).
EDIT: Or should I use LIKE in SQL?

Related

How to accomplish full text search in MySQL 5.5 Engine = innodb?

I've gone through many articles but didn't find how can I do it alternate to match and against. In one of my project I need to use this and it is not suitable to upgrade the version of the database.
Is there any way?

Search Engine using php , InnoDB Engine Mysql

SELECT firstname, lastname,comments
FROMusers
WHERE MATCH(firstname,lastname,comments)
AGAINST('$searchterm')
I tried the above one as query for search engine ,but mysql says FULL-TEXT INDEXING is supported only on MYISAM ,Engine i am using is innoDB,Please tell me the best way of coloumn INDEX searching ON InnoDB Engine.
Based on my knowledge, MySQL FTS has been available for InnoDB since version 5.6 (http://dev.mysql.com/tech-resources/articles/whats-new-in-mysql-5.6.html)
You should take a look at MySQL Fulltex search document here http://dev.mysql.com/doc/refman/5.5/en/fulltext-search.html
Basically, I think you should understand what is 'index' and how MySQL do indexing. This article is very useful for helping understand the mechanism behind MySQL fulltext search http://dev.mysql.com/doc/internals/en/full-text-search.html
There are several important concepts in full-text search:
Boolean mode
Natural language mode
I also recommend you read about stopwords list in MySQL FTS.
System variable likes ft_min_word_len is also important.
After understanding these things, I think you will know how to apply MySQL fulltext search properly.

InnoDB full-text search (no lucene)

I have a problem. I have a managed VPS server running MySQL 5.1.x. I am currently building a new database where I want to store tweets (via search, stream, timeline etc). So I want to use InnoDB database engine because of the row locking! But unfortunately, MySQL 5.1 does not support Full-text search in InnoDB tables.
The problem is that I cannot update my server by myself. So I cannot install MySQL 5.6 (that should support Full-text search) and I cannot install lucene (or solr or whatever).
Are there other options to achieve Full-text search in MySQL or whatever. Or maybe in PostgreSQL (never used that before)
The only other option I have so far is going to an unmanaged VPS but I don't prefer that :)
You can take a look to MyISAM engine but it's not transactional.
The other other possible solution is create another table with engine MyISAM or ARIA and create a relationship between the new table and the "store tweets" table, so before insert into the 'new table' make sure that 'store tweets' it's not locked.

An alternative to MySQL fulltext search

I read that MySQL fulltext search can cause table locking. It means people can't insert or update the table when it's being searched on.
I read that there are many search servers (Lucence and Sphinx) can do it without table locking and even faster. It requires many configuration and hard to implement.
Is there any other way to use fulltext or some searching like that without using search service? I don't want to configure one more server other than MySQL.
Create an extra table which will be used only to perform FULLTEXT searches. In your code you have to ensure that all data and actions (create, update, delete) are properly replicated to this table. This solution is also handy if your data tables are running e.g. InnoDB engine.
Apache Lucene doesn't need many configuration and isn't hard to implement. Moreover, it's one of the most popular fulltext search engine, and allows the users to do very precise queries, like "to be or not to be", j?hn d?e, func*, etc.
I already did some database indexing with Lucene, so if you could be a bit more precise about which fields of which tables you wanna index, I can give you pieces of code which should do the trick.
I vote for Sphinxsearch anyway. It has one of APIs close to Mysql, easy to install and configure. Not so universal as Apache Lucene, but jet quick and very helpful in my projects.

Any third party search engines (fulltext search and so on) work fine with InnoDB tables?

I know, that InnoDB tables do not support fulltext searches, yet. So I thought of using a third party search engine like solr, xapian or whoosh. Do those third party tools work equivalently fine with InnoDB tables as they work with MyIsam tables? I need to find e.g. spelling suggestions, and similar strings...
You could use Solr/Lucene to do the fulltext-search over your DB data. Since my MySQL DB is to big for an fast fulltext-search, i decided to combine mysql and Solr/lucene.
It's important to know, that Solr/Lucene is not an MySQL Plugin. So you will not be able to search the fulltext-index by using typical MySQL SQL-Statements. An fulltext-search, initiated by the application, should be first send the request to the 3rd party fulltext-index (Solr), which returns the primary keys of the related documents. Second step is to run an SQL statement against your MySQL innoDB with an where clause with the corresponding primary keys from the Solr result set.
That solution works in my case very well and much, much faster (and better) than an typical MySQL Myisam fulltext-search.
As an alternative you could not only index the data in solr. You also could store the data in solr additionally. In that case, solr is able to return the full text. So you don't need get the data form the database, as in the example above.
Do those third party tools work equivalently fine with InnoDB tables as they work with MyIsam tables?
Absolutely. Solr has an DataImportHandler. Ther you define an SQL statement in order to get the data you like to index in solr, like: select * from MyTable;
But keep in mind: right now (as far as I know) ther is no MySQL solr plugin available. The cooperation of Solr and MySQL should be handled by the application.
Third-party fulltext search engines typically copy data returned by a MySQL query, and use it to populate their search index. There's no difference between MyISAM and InnoDB data sources in this respect.
I gave a presentation Practical Full-Text Search in MySQL a few years ago. You might find it interesting.
Sphinx supports its own index and just takes data from MySQL on a timely basis by issuing a query.
It is not even aware of the underlying table structure and as long as the query runs and returns the results, it's OK for Sphinx.
Other third party engines work in a similar way.