{"id":60680,"date":"2018-10-08T11:00:19","date_gmt":"2018-10-08T08:00:19","guid":{"rendered":"http:\/\/examples.javacodegeeks.com\/?p=60680"},"modified":"2018-10-05T09:51:51","modified_gmt":"2018-10-05T06:51:51","slug":"mysql-full-text-search-tutorial","status":"publish","type":"post","link":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/","title":{"rendered":"MySQL Full-text Search Tutorial"},"content":{"rendered":"<h2 id=\"introduction\">1. Introduction<\/h2>\n<p><a href=\"https:\/\/www.mysql.com\/\" target=\"_blank\" rel=\"noopener\">MySQL<\/a>\u00a0is one of the most used SQL databases in many of the world-enterprise applications due to its ability to manage transactions and the ACID-behaviour which is built into its core. One of the reasons MySQL is so popular is due to the easiness it provides for its usage and its related commands. In the open source web application framework <a href=\"https:\/\/www.javacodegeeks.com\/2016\/10\/lamp-stacks-iot.html\" target=\"_blank\" rel=\"noopener\">LAMP<\/a> (which consist of Linux, Apache, MySQL and PHP),\u00a0MySQL server is a central &amp; important component. The MySQL Database server is written using C and C++ which internally uses\u00a0a lexical analyser to parse and understand the SQL queries.<\/p>\n<p>With time, many full-text search databases have come up with fast indexes which are exclusively made for supporting scalable and efficient\u00a0full-text search functionality like <a href=\"https:\/\/www.javacodegeeks.com\/2017\/02\/elasticsearch-java-developers-elasticsearch-command-line.html\" target=\"_blank\" rel=\"noopener\">Elasticsearch<\/a>, <a href=\"https:\/\/examples.javacodegeeks.com\/enterprise-java\/apache-solr\/apache-solr-tutorial-beginners\/\" target=\"_blank\" rel=\"noopener\">Apache Solr<\/a> and <a href=\"https:\/\/www.javacodegeeks.com\/2018\/08\/mongodb-index-strategies-and-types-of-indexes.html\" target=\"_blank\" rel=\"noopener\">MongoDB<\/a> as well. That ease when you start typing something in a search box and results start to follow as you type, it is one of the implementations for full-text search.<\/p>\n<div class=\"toc\">\n<h3>Table Of Contents<\/h3>\n<dl>\n<dt><a href=\"#introduction\">1. Introduction<\/a><\/dt>\n<dt><a href=\"#mysql_setup\">2. MySQL Setup<\/a><\/dt>\n<dt><a href=\"#full_text_search\">3. Full-text Search with MySQL<\/a><\/dt>\n<dt><a href=\"#full_text_indexes\">4. Defining\u00a0Full-text indexes in MySQL<\/a><\/dt>\n<dt><a href=\"#start_full_text_search\">5. Introduction to\u00a0Full-text searches in MySQL<\/a><\/dt>\n<dt><a href=\"#boolean_text_search\">6. Boolean\u00a0Full-text searches in MySQL<\/a><\/dt>\n<dt><a href=\"#query_expansion\">7. Query Expansion with MySQL Full-Text Search<\/a><\/dt>\n<dt><a href=\"#performance\">8. Performance of Full-text searches in MySQL<\/a><\/dt>\n<dt><a href=\"#comparison\">9. Comparison: MySQL vs Elasticsearch full-text search<\/a><\/dt>\n<dt><a href=\"#conclusion\">10. Conclusion: MySQL Full-text Search<\/a><\/dt>\n<\/dl>\n<\/div>\n<h2 id=\"mysql_setup\">2. MySQL Setup<\/h2>\n<p>For this lesson, we make a new server which we will be using as our MySQL installation. To proceed further, we need to set up MySQL Server and Client tools on that server. We can do this by executing the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Installing MySQL Server and Client<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo apt-get install mysql-server mysql-client\r\n<\/pre>\n<p>Once we run this command, the mentioned utilities will be installed on the server. While installing, we also set a MySQL root password:<\/p>\n<div id=\"attachment_60518\" class=\"wp-caption aligncenter\">\n<figure id=\"attachment_60518\" aria-describedby=\"caption-attachment-60518\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png\"><img decoding=\"async\" class=\"wp-image-60518 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png\" alt=\"MySQL Full-text Search - Setting Root Password\" width=\"820\" height=\"378\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql-300x138.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/setting-root-password-mysql-768x354.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60518\" class=\"wp-caption-text\">Setting Root Password<\/figcaption><\/figure>\n<\/div>\n<p>Once the installation process is completed, we can confirm if the MySQL server is up and running with the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Check MySQL Service status<\/em><\/span><\/p>\n<pre class=\"brush:bash\">sudo service mysql status\r\n<\/pre>\n<p>We will see an output like this:<\/p>\n<div id=\"attachment_60520\" class=\"wp-caption aligncenter\">\n<figure id=\"attachment_60520\" aria-describedby=\"caption-attachment-60520\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png\"><img decoding=\"async\" class=\"wp-image-60520 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png\" alt=\"MySQL Full-text Search - Check MySQL Server Status\" width=\"820\" height=\"304\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status-300x111.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-status-768x285.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60520\" class=\"wp-caption-text\">Check MySQL Server Status<\/figcaption><\/figure>\n<\/div>\n<p>Now that we know that the MySQL server is up and running, we can connect to it using the username and password we supplied to it during the installation process. We can use the following command to do so:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Logging into MySQL<\/em><\/span><\/p>\n<div id=\"highlighter_305288\" class=\"syntaxhighlighter \">\n<div class=\"lines\">\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>1<\/code><\/td>\n<td class=\"content\"><code class=\"plain\">mysql -u root -p<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<p>When we press enter, MySQL Server will silently wait for us to provide the password. When we type it, the password will not be echoed back to the terminal due to security reasons. We will see the following prompt once we have logged into the MySQL command line:<\/p>\n<div id=\"attachment_60522\" class=\"wp-caption aligncenter\">\n<figure id=\"attachment_60522\" aria-describedby=\"caption-attachment-60522\" style=\"width: 820px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png\"><img decoding=\"async\" class=\"wp-image-60522 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png\" alt=\"MySQL Full-text Search - MySQL Login\" width=\"820\" height=\"304\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login.png 820w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login-300x111.png 300w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-login-768x285.png 768w\" sizes=\"(max-width: 820px) 100vw, 820px\" \/><\/a><figcaption id=\"caption-attachment-60522\" class=\"wp-caption-text\">MySQL Login<\/figcaption><\/figure>\n<\/div>\n<p>When we are inside the MySQL command prompt, we can use the given command to show the databases which are present in the system and to ensure that MySQL is running fine:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Show All databases<\/em><\/span><\/p>\n<div id=\"highlighter_636899\" class=\"syntaxhighlighter \">\n<div class=\"lines\">\n<div class=\"line alt1\">\n<table>\n<tbody>\n<tr>\n<td class=\"number\"><code>1<\/code><\/td>\n<td class=\"content\"><code class=\"plain\">show databases;<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<\/div>\n<\/div>\n<\/div>\n<p>Here is what we get back with this command:<\/p>\n<div id=\"attachment_60525\" class=\"wp-caption aligncenter\">\n<figure id=\"attachment_60525\" aria-describedby=\"caption-attachment-60525\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png\"><img decoding=\"async\" class=\"wp-image-60525 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png\" alt=\"MySQL Full-text Search - Check MySQL Databases\" width=\"570\" height=\"255\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list.png 570w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/mysql-database-list-300x134.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><figcaption id=\"caption-attachment-60525\" class=\"wp-caption-text\">Check MySQL Databases<\/figcaption><\/figure>\n<\/div>\n<p>In the output, MySQL just displays the list of MySQL default databases that are used for administration purpose. As this is our fresh installation, only four databases are visible as of now which are made by MySQL itself. Now that we know that our MySQL set up is complete and running, we can start working with full-text search in MySQL but we must first understand properly what it is and how it works in MySQL.<\/p>\n<h2 id=\"full_text_search\">3. Full-text Search with MySQL<\/h2>\n<p>If you want to find textual data similar to given values, MySQL database supports the use of\u00a0<strong>LIKE<\/strong> operator and regular expressions as well. But these methods start to create performance bottlenecks when the amount of data grow in your database and text values grow in large number in themselves (like when we start to save complete paragraph or pages of documents in a database column). Let us point down the\u00a0<strong>important drawbacks<\/strong> for LIKE operator and regular expression usage:<\/p>\n<ul>\n<li><strong>Performance<\/strong>: When LIKE operator is used, MySQL performs a\u00a0<strong>full-table scan<\/strong> to search for given values of text which is extremely slow when the amount of data is more.<\/li>\n<li><strong>Flexibility<\/strong>: The queries for flexible use-cases becomes complex than they should be. Like when we want to search for posts which contain &#8220;MySQL&#8221; but not &#8220;LIKE operator&#8221;, the query is not very much flexible.<\/li>\n<li><strong>Ranking mechanism<\/strong>: There is no way with which we can get a sense of strongness with the response we get with these operators as they return the results in the order they find it and not in the order of similarity in which the data has matched against the query text.<\/li>\n<\/ul>\n<p>To allow overcome these limitations, MySQL has a nice feature called\u00a0<strong>full-text search\u00a0<\/strong>which has nice advantages over\u00a0<strong>LIKE<\/strong> operator and regular expressions:<div style=\"display:inline-block; margin: 15px 0;\"> <div id=\"adngin-JavaCodeGeeks_incontent_video-0\" style=\"display:inline-block;\"><\/div> <\/div><\/p>\n<ul>\n<li>Even complex queries start to perform very well with MySQL text search<\/li>\n<li>The index made to support full-text are extremely efficient when it comes to occupying hard disk and memory space usage<\/li>\n<li>The indexes are updated in near real-time as soon as the values change in main columns supporting full-text search<\/li>\n<\/ul>\n<p>Now that we have a basic idea about what full-text search is, we can start looking at how we can start implementing and building indexes for the full-text search for our database. This is what we will be doing in the\u00a0next sections.<\/p>\n<h2 id=\"full_text_indexes\">4. Defining\u00a0Full-text indexes in MySQL<\/h2>\n<p>In this section, we will learn about defining full-text search indexes for our table columns. Before we can perform the full-text search on our data, we must index its data first. Once the data in that column is updated, the index is recalculated for the changes made. We can define the\u00a0full-text search indexes with the keyword\u00a0<code>FULLTEXT<\/code>. The good thing is that even if the column being indexed already has some data, as soon as we make an index around that column, the index is populated with complete data automatically and this isn&#8217;t a manual process.<\/p>\n<p>For demonstration purposes, we have made a database <code>jcg_schema<\/code> and some tables inside it.<\/p>\n<p><figure id=\"attachment_60704\" aria-describedby=\"caption-attachment-60704\" style=\"width: 578px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-search-database.png\"><img decoding=\"async\" class=\"wp-image-60704 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-search-database.png\" alt=\"MySQL Full-text Search - The database and table for Search\" width=\"578\" height=\"483\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-search-database.png 578w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-search-database-300x251.png 300w\" sizes=\"(max-width: 578px) 100vw, 578px\" \/><\/a><figcaption id=\"caption-attachment-60704\" class=\"wp-caption-text\">The database and table for Search<\/figcaption><\/figure><\/p>\n<p>There are three ways with which full-text indexes can be made.<\/p>\n<h3 id=\"index_create_table\">4.1 Defining FULLTEXT index while creating a Table<\/h3>\n<p>We can define columns for which we need to create full-text index with the <code>FULLTEXT<\/code> keyword as shown here:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index while creating Table<\/em><\/span><\/p>\n<pre class=\"brush:bash\">CREATE TABLE table_name (\r\n column1 data_type, \r\n        column2 data_type,\r\n\u2026 more columns ..\r\nPRIMARY_KEY(key_column),\r\nFULLTEXT (column1,column2,..)\r\n);\r\n<\/pre>\n<p>For our database, we will create a new table <code>Posts<\/code> with the following schema and full-text index as well:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index while creating Table<\/em><\/span><\/p>\n<pre class=\"brush:bash\">CREATE TABLE Posts (\r\n  id INT PRIMARY KEY,\r\n  title VARCHAR(64) NOT NULL,\r\n  author_id INT NOT NULL,\r\n  FULLTEXT (title)\r\n);\r\n<\/pre>\n<p>When we describe this table structure, we will see the following:<\/p>\n<p><figure id=\"attachment_60705\" aria-describedby=\"caption-attachment-60705\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-create-table-index.png\"><img decoding=\"async\" class=\"wp-image-60705 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-create-table-index.png\" alt=\"MySQL Full-text Search - Create Index while making a Table\" width=\"570\" height=\"388\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-create-table-index.png 570w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-create-table-index-300x204.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><figcaption id=\"caption-attachment-60705\" class=\"wp-caption-text\">Create Index while making a Table<\/figcaption><\/figure><\/p>\n<h3 id=\"index_existing_table\">4.2 Defining FULLTEXT index for existing Tables<\/h3>\n<p>In the last section, we created a new table with a full-text index. It is possible to create a full-text index on a column in an existing column as well. For this purpose, we will use the <code>Author<\/code> table we created earlier. For this purpose, we can use the following command syntax:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index on existing Tables<\/em><\/span><\/p>\n<pre class=\"brush:bash\">ALTER TABLE  table_name  \r\nADD FULLTEXT(column1,column2,..);\r\n<\/pre>\n<p>To illustrate this with an example, we will add the full-text index on <code>Author<\/code> table&#8217;s <code>name<\/code> column:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index on existing Tables<\/em><\/span><\/p>\n<pre class=\"brush:bash\">ALTER TABLE Author  \r\nADD FULLTEXT(name);\r\n<\/pre>\n<p>Once this query is executed, we will see the following output:<\/p>\n<p><figure id=\"attachment_60706\" aria-describedby=\"caption-attachment-60706\" style=\"width: 570px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/create-index-existing-table-mysql.png\"><img decoding=\"async\" class=\"wp-image-60706 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/create-index-existing-table-mysql.png\" alt=\"MySQL Full-text Search - Create index on existing table\" width=\"570\" height=\"331\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/create-index-existing-table-mysql.png 570w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/create-index-existing-table-mysql-300x174.png 300w\" sizes=\"(max-width: 570px) 100vw, 570px\" \/><\/a><figcaption id=\"caption-attachment-60706\" class=\"wp-caption-text\">Create index on existing table<\/figcaption><\/figure><\/p>\n<h3 id=\"index_create_index\">4.3 Defining FULLTEXT index with Create Index statement<\/h3>\n<p>In the last section, we defined a full-text index on an existing column with <code>ALTER<\/code> command. In this section, we will use an explicit <code>CREATE INDEX<\/code> command which hae the following syntax:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index explicit command<\/em><\/span><\/p>\n<pre class=\"brush:bash\">CREATE FULLTEXT INDEX index_name\r\nON table_name(idx_column_name,...);\r\n<\/pre>\n<p>As clearly mentioned, this command also allows us to provide an explicit <code>index_name<\/code> to the index as well. It makes it easier to identify the indexes which reside in our database for later queries and size identification of the index. For demonstration, here is the command we will use for the same column <code>name<\/code> in the <code>Author<\/code> table:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Create Index explicit command<\/em><\/span><\/p>\n<pre class=\"brush:bash\">CREATE FULLTEXT INDEX name_idx\r\nON Author(name);\r\n<\/pre>\n<p>Please note that if you want to load large amount of data in a given table which has an existing FULLTEXT index present, it will be much faster if:<\/p>\n<ul>\n<li>Remove the <code>FULLTEXT<\/code> index from the column<\/li>\n<li>Load the required data into the table<\/li>\n<li>Add the <code>FULLTEXT<\/code> index on the required column<\/li>\n<\/ul>\n<p>This is necessary to do as if a <code>FULLTEXT<\/code> index exists on a column, after every insertion, this index will be recalculated which is a synchronous process and will make insertions pretty slow. That is why the removal of the index temporarily makes this pretty fast. To remove a <code>FULLTEXT<\/code> index from the column, we can use the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Remove Index <\/em><\/span><\/p>\n<pre class=\"brush:bash\">ALTER TABLE Author\r\nDROP INDEX name_idx;\r\n<\/pre>\n<h2 id=\"start_full_text_search\">5. Introduction to\u00a0Full-text searches in MySQL<\/h2>\n<p>We will start with understanding how <strong>natural language<\/strong> full-text search works in MySQL. With natural language\u00a0full-text search, MySQL can extract data which is relevant to the passed query text which is in natural form, like &#8220;How many Authors have a name starting with S&#8221;. It also provides a\u00a0<strong>relevance score<\/strong> to the returned data which means that <strong>higher the score, more it is similar to the passed query<\/strong>. There are various factors which affect this score, like:<\/p>\n<ul>\n<li>Number of words in the document<\/li>\n<li>Total number of words in the collection or table<\/li>\n<li>Unique word count in the document<\/li>\n<li>Document count which contains the given set of words<\/li>\n<\/ul>\n<p>There are two functions which can perform the full-text search in MySQL,\u00a0<code>MATCH()<\/code> and <code>AGAINST()<\/code> functions. Let&#8217;s look at how to use each of them here.<\/p>\n<p>As we already have some data in the <code>Author<\/code> table, we can use the <code>MATCH()<\/code> and <code>AGAINST()<\/code> functions to get a relevance score with a text query to findout if something matches to our query or not. We will use the following command:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Relevance score with MATCH() function<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SELECT id, MATCH(name) AGAINST ('Oshima') as score\r\nFROM Author\r\nWHERE MATCH(name) AGAINST ('Oshima') &gt; 0 ORDER BY score DESC;\r\n<\/pre>\n<p>Once we run this command, we will get the following result:<\/p>\n<p><figure id=\"attachment_60710\" aria-describedby=\"caption-attachment-60710\" style=\"width: 562px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-text-search-match-relevance.png\"><img decoding=\"async\" class=\"wp-image-60710 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-text-search-match-relevance.png\" alt=\"MySQL Full-text Search - Full-text search response for Match function\" width=\"562\" height=\"464\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-text-search-match-relevance.png 562w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-text-search-match-relevance-300x248.png 300w\" sizes=\"(max-width: 562px) 100vw, 562px\" \/><\/a><figcaption id=\"caption-attachment-60710\" class=\"wp-caption-text\">Full-text search response for Match function<\/figcaption><\/figure><\/p>\n<p>Please note that we need to repeat the <code>MATCH()<\/code> and <code>AGAINST()<\/code> function in the <code>WHERE<\/code> clause because of SQL restrictions on what can be included in that clause.<br \/>\nWe used 0 as a cutoff here. We can increase that value as much as we want to fine-tune and limit the accurate results we get back with these queries.<\/p>\n<p>While this is exciting to see our results in a sorted manner of a relevance score, it is also important to note some important points:<\/p>\n<ul>\n<li>The minimum length of the string we can use to search is 4. This means that when we try to search a string like &#8220;car&#8221; or &#8220;see&#8221;, we will not get back any results.<\/li>\n<li>Stop words are ignored by MySQL, which are defined in the MySQL source code distribution <code>storage\/myisam\/ft_static.c<\/code>.<\/li>\n<\/ul>\n<h2 id=\"boolean_text_search\">6. Boolean\u00a0Full-text searches in MySQL<\/h2>\n<p>In Boolean\u00a0Full-text searches in MySQL, we can also exclude words while performing a search or define a range of how far away the words in the input must be from one another. To exclude a term from the query, we can make use of the minus operator with <code>IN BOOLEAN<\/code> keyword. Let us consider the following example where response should contain &#8216;module&#8217; but not &#8216;getpass&#8217;:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Relevance score with MATCH() function<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SELECT *\r\nFROM Posts\r\nWHERE MATCH(title) AGAINST ('module -getpass IN BOOLEAN MODE');\r\n<\/pre>\n<p>This is what we get back with this command:<\/p>\n<p><figure id=\"attachment_60713\" aria-describedby=\"caption-attachment-60713\" style=\"width: 738px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-exclude-terms-boolean.png\"><img decoding=\"async\" class=\"wp-image-60713 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-exclude-terms-boolean.png\" alt=\"MySQL Full-text Search - MySQL exclude terms from match using boolean Mode\" width=\"738\" height=\"559\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-exclude-terms-boolean.png 738w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-exclude-terms-boolean-300x227.png 300w\" sizes=\"(max-width: 738px) 100vw, 738px\" \/><\/a><figcaption id=\"caption-attachment-60713\" class=\"wp-caption-text\">MySQL exclude terms from match using boolean Mode<\/figcaption><\/figure><\/p>\n<p>For demonstration, we also displayed complete data which was present in the &#8216;Posts&#8217; table before we perform the Boolean full-text search query.<\/p>\n<p>The Boolean full-text search has some excellent features which we should know about:<\/p>\n<ul>\n<li>The relevance order sorting doesn&#8217;t apply on Boolean full-text search results as it did with the Match and Against functions<\/li>\n<li>If you want to perform the Boolean full-text search queries on a column, the InnoDB mandates having a FULLTEXT index on that column<\/li>\n<li>Multiple Boolean operators are not allowed in Boolean full-text search queries, MySQL will show an error if this is tried<\/li>\n<li>Boolean full-text search queries only support leading + or &#8211; operators and not the trailing operators<\/li>\n<\/ul>\n<h2 id=\"query_expansion\">7. Query Expansion with MySQL Full-Text Search<\/h2>\n<p>It is a very common scenario when a user of an application <strong>doesn&#8217;t exactly know what he needs to search for<\/strong>. They can define some random keywords they have an idea about and still expect correct results from the application. This is where MySQL query expansion comes in which allows a user to use <strong>too-short keywords<\/strong> in their queries and still get relevant results.<\/p>\n<p>It widens the search results of the full-text search result based on\u00a0<strong>blind query expansion<\/strong>. These are steps MySQL follow to do so:<\/p>\n<ul>\n<li>It starts by performing a search with given short keywords itself to get highly accurate results<\/li>\n<li>It checks all search results and looks for the relevant words<\/li>\n<li>Finally, it performs a search again based on those relevant words instead of the original query passed by the user<\/li>\n<\/ul>\n<p>Query expansion has simple syntax like:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Query Expansion Syntax<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SELECT column1, column2\r\nFROM table1\r\nWHERE MATCH(column1,column2) \r\n      AGAINST('keyword',WITH QUERY EXPANSION);\r\n<\/pre>\n<p>Let;s run our own query to see how it actually works on the <code>name<\/code> column which already have the <code>FULLTEXT<\/code> index enabled for it. We can run the query like:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>Without Query Expansion<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SELECT *\r\nFROM Posts\r\nWHERE MATCH(title) AGAINST ('module');\r\n<\/pre>\n<p>Here are the results we get with this query:<\/p>\n<p><figure id=\"attachment_60719\" aria-describedby=\"caption-attachment-60719\" style=\"width: 650px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-without-query-expansion.png\"><img decoding=\"async\" class=\"wp-image-60719 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-without-query-expansion.png\" alt=\"MySQL Full-text Search - Without Query Expansion\" width=\"650\" height=\"616\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-without-query-expansion.png 650w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-without-query-expansion-300x284.png 300w\" sizes=\"(max-width: 650px) 100vw, 650px\" \/><\/a><figcaption id=\"caption-attachment-60719\" class=\"wp-caption-text\">Without Query Expansion<\/figcaption><\/figure><\/p>\n<p>Let us try again with a modified query which uses query expansion:<\/p>\n<p><span style=\"text-decoration: underline;\"><em>With Query Expansion<\/em><\/span><\/p>\n<pre class=\"brush:bash\">SELECT *\r\nFROM Posts\r\nWHERE MATCH(title) AGAINST ('module' WITH QUERY EXPANSION);\r\n<\/pre>\n<p>Here are the results we get with this query:<\/p>\n<p><figure id=\"attachment_60720\" aria-describedby=\"caption-attachment-60720\" style=\"width: 626px\" class=\"wp-caption aligncenter\"><a href=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-with-query-expansion.png\"><img decoding=\"async\" class=\"wp-image-60720 size-full\" src=\"http:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-with-query-expansion.png\" alt=\"MySQL Full-text Search - With Query Expansion\" width=\"626\" height=\"635\" srcset=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-with-query-expansion.png 626w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-with-query-expansion-296x300.png 296w, https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/10\/mysql-with-query-expansion-70x70.png 70w\" sizes=\"(max-width: 626px) 100vw, 626px\" \/><\/a><figcaption id=\"caption-attachment-60720\" class=\"wp-caption-text\">With Query Expansion<\/figcaption><\/figure><\/p>\n<p>Clearly the result for two queries vary and we get much more results with query expansion and often, we will get much more relevant results with query expansion. This can be used when we need to show user a list of results which can be near to his query text but not exactly the same. The results are still relevant and can be kept at a lower position when shown to the user.<\/p>\n<h2 id=\"performance\">8. Performance of Full-text searches in MySQL<\/h2>\n<p>To identify the performance of Full-text search in an application, the first thing to look for is the amount of data present in the table we want to search. If the number of records is too less and the search queries are pretty simple, using a FULLTEXT index and the Match functions will simply be an overhead. To import some main points which we have learned while working on the database search with MySQL, here we summarise these points:<\/p>\n<ul>\n<li>If record count for the table is below 250k, it is better when we use LIKE operator itself because it only takes a fraction of a second to return the results. We also need to take note that a view can easily take many times more to render the response.<\/li>\n<li>The\u00a0FULLTEXT indexes perform better with a wide range of vocabulary as the indexes made are wide but shallow which can determine very quickly if the passed query string has any matches in the database or not.<\/li>\n<li>Interestingly, both LIKE operator and the\u00a0FULLTEXT index approach scales linearly. Note that even the\u00a0FULLTEXT index have limitations, like when your table reaches multi-million records, it will create pain in response times and we can move to a NoSQL solution like Elasticsearch to provide free-text search capabilities for an application.<\/li>\n<\/ul>\n<p>It is important to know when to stop trying to scale a full-text search with MySQL because of its limited capabilities with performance when the data size in application grows to multi-million records, which is pretty much achievable quickly in an application for today&#8217;s world when big data is so advent. This means that moving out to a NoSQL database if you have a use case related to text search is a smart choice from the beginning itself. No doubt that MySQL search is easy to perform and has good documentation, it is necessary to pick a solution which you won&#8217;t doubt for the next 5 years of your application&#8217;s life.<\/p>\n<h2 id=\"comparison\">9. Comparison: MySQL vs Elasticsearch full-text search<\/h2>\n<p>Every text search solution is as powerful as the text analysis capabilities it offers. <a href=\"https:\/\/www.javacodegeeks.com\/2015\/09\/apache-lucene-fundamentals.html\" target=\"_blank\" rel=\"noopener\">Lucene<\/a>, the underlying search engine for Elasticsearch, is such an\u00a0open source information retrieval library offering many text analysis possibilities. When it comes to querying performance, the Elasticsearch performance will always outlive MySQL performance and this is clearly visible in <a href=\"https:\/\/www.javacodegeeks.com\/2014\/07\/use-cases-for-elasticsearch-full-text-search.html\" target=\"_blank\" rel=\"noopener\">the use cases Elasticsearch is used for<\/a>.<\/p>\n<p>The examples we studied in this lesson were quite simple. What if we want to cover much more complex examples with the query engine integrated into our system, like the engine:<\/p>\n<ul>\n<li>should look for synonyms matching my query text<\/li>\n<li>should match singular and plural words or words sounding similar to enter query text<\/li>\n<li>should not allow searching on protected words<\/li>\n<li>should allow a search for words mixed with numeric or special characters<\/li>\n<li>should not allow search on HTML tags<\/li>\n<li>should allow search text based on the proximity of the letters and number of matching letters<\/li>\n<\/ul>\n<p>Enriching the content here would be to add above search capabilities to your content while indexing and searching for the content.\u00a0ElasticSearch uses Lucene inbuilt capabilities of text analysis and allows you to enrich your search content. ElasticSearch offers us quite some inbuilt analyzers with preconfigured tokenizers and filters. For details list of existing analyzers, check complete list for\u00a0<a title=\"analysis\" href=\"http:\/\/www.elasticsearch.org\/guide\/reference\/index-modules\/analysis\/\" target=\"_blank\" rel=\"noopener\">Analysis<\/a>.<\/p>\n<p>With MySQL, indexes will always stay busy in indexing and searching the data for response and it will be soon when you start pitying them to making them do so much of the work.<\/p>\n<h2 id=\"conclusion\">10. Conclusion: MySQL Full-text Search<\/h2>\n<p>MySQL full-text search is an excellent choice (besides its disadvantages and limitations) when it comes to making sure that a user gets a fast response when he tries to perform full-text searches on the database or the application using MySQL database. It surely has some disadvantages related to scaling but for simpler applications, it is a very good starting point with one of the most popular databases used today.<\/p>\n<p>Although Elasticsearch and related Lucene-based engines can provide much better full-text search engines and response times, we would suggest that you start with MySQL text search, as in a simple case it will be quick to set up and if this does not provide what you need then upgrade to elastic search. You will at least have a straw man feature which can be used to further refine your search requirements. This is exactly what this lesson aimed to do.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Introduction MySQL\u00a0is one of the most used SQL databases in many of the world-enterprise applications due to its ability to manage transactions and the ACID-behaviour which is built into its core. One of the reasons MySQL is so popular is due to the easiness it provides for its usage and its related commands. In &hellip;<\/p>\n","protected":false},"author":154,"featured_media":1204,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[53],"tags":[647,1055],"class_list":["post-60680","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sql","tag-mysql","tag-sql"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>MySQL Full-text Search Tutorial - Java Code Geeks<\/title>\n<meta name=\"description\" content=\"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"MySQL Full-text Search Tutorial - Java Code Geeks\" \/>\n<meta property=\"og:description\" content=\"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!\" \/>\n<meta property=\"og:url\" content=\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\" \/>\n<meta property=\"og:site_name\" content=\"Examples Java Code Geeks\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/javacodegeeks\" \/>\n<meta property=\"article:published_time\" content=\"2018-10-08T08:00:19+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"150\" \/>\n\t<meta property=\"og:image:height\" content=\"150\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"Shubham Aggarwal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@sbmaggarwal\" \/>\n<meta name=\"twitter:site\" content=\"@javacodegeeks\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Shubham Aggarwal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"16 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\"},\"author\":{\"name\":\"Shubham Aggarwal\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2\"},\"headline\":\"MySQL Full-text Search Tutorial\",\"datePublished\":\"2018-10-08T08:00:19+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\"},\"wordCount\":3011,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"keywords\":[\"mysql\",\"sql\"],\"articleSection\":[\"sql\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\",\"name\":\"MySQL Full-text Search Tutorial - Java Code Geeks\",\"isPartOf\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"datePublished\":\"2018-10-08T08:00:19+00:00\",\"description\":\"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!\",\"breadcrumb\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg\",\"width\":150,\"height\":150,\"caption\":\"Bipartite Graph\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/examples.javacodegeeks.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Java Development\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Core Java\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/\"},{\"@type\":\"ListItem\",\"position\":4,\"name\":\"sql\",\"item\":\"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/\"},{\"@type\":\"ListItem\",\"position\":5,\"name\":\"MySQL Full-text Search Tutorial\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#website\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"name\":\"Java Code Geeks\",\"description\":\"Java Examples and Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\"},\"alternateName\":\"JCG\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#organization\",\"name\":\"Exelixis Media P.C.\",\"url\":\"https:\/\/examples.javacodegeeks.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png\",\"width\":864,\"height\":246,\"caption\":\"Exelixis Media P.C.\"},\"image\":{\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/javacodegeeks\",\"https:\/\/x.com\/javacodegeeks\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2\",\"name\":\"Shubham Aggarwal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg\",\"contentUrl\":\"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg\",\"caption\":\"Shubham Aggarwal\"},\"description\":\"Shubham is a Java Backend and Data Analytics Engineer with more than 3 years of experience in building quality products with Spring Boot, MongoDB, Elasticsearch, MySQL, Docker, AWS, Git, PrestoDB tools and I have a deep knowledge and passion towards analytics, Micro-service based architecture, design patterns, antipatterns and software design thinking.\",\"sameAs\":[\"https:\/\/www.linkedin.com\/in\/sbmaggarwal\/\",\"https:\/\/x.com\/sbmaggarwal\"],\"url\":\"https:\/\/examples.javacodegeeks.com\/author\/shubham-aggarwal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"MySQL Full-text Search Tutorial - Java Code Geeks","description":"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/","og_locale":"en_US","og_type":"article","og_title":"MySQL Full-text Search Tutorial - Java Code Geeks","og_description":"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!","og_url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/","og_site_name":"Examples Java Code Geeks","article_publisher":"https:\/\/www.facebook.com\/javacodegeeks","article_published_time":"2018-10-08T08:00:19+00:00","og_image":[{"width":150,"height":150,"url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","type":"image\/jpeg"}],"author":"Shubham Aggarwal","twitter_card":"summary_large_image","twitter_creator":"@sbmaggarwal","twitter_site":"@javacodegeeks","twitter_misc":{"Written by":"Shubham Aggarwal","Est. reading time":"16 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#article","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/"},"author":{"name":"Shubham Aggarwal","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2"},"headline":"MySQL Full-text Search Tutorial","datePublished":"2018-10-08T08:00:19+00:00","mainEntityOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/"},"wordCount":3011,"commentCount":2,"publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","keywords":["mysql","sql"],"articleSection":["sql"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/","url":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/","name":"MySQL Full-text Search Tutorial - Java Code Geeks","isPartOf":{"@id":"https:\/\/examples.javacodegeeks.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage"},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage"},"thumbnailUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","datePublished":"2018-10-08T08:00:19+00:00","description":"Interested to learn more about MySQL? Then check out our detailed example on MySQL Full-text Search!","breadcrumb":{"@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#primaryimage","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2012\/12\/java-logo.jpg","width":150,"height":150,"caption":"Bipartite Graph"},{"@type":"BreadcrumbList","@id":"https:\/\/examples.javacodegeeks.com\/java-development\/core-java\/sql\/mysql-full-text-search-tutorial\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/examples.javacodegeeks.com\/"},{"@type":"ListItem","position":2,"name":"Java Development","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/"},{"@type":"ListItem","position":3,"name":"Core Java","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/"},{"@type":"ListItem","position":4,"name":"sql","item":"https:\/\/examples.javacodegeeks.com\/category\/java-development\/core-java\/sql\/"},{"@type":"ListItem","position":5,"name":"MySQL Full-text Search Tutorial"}]},{"@type":"WebSite","@id":"https:\/\/examples.javacodegeeks.com\/#website","url":"https:\/\/examples.javacodegeeks.com\/","name":"Java Code Geeks","description":"Java Examples and Code Snippets","publisher":{"@id":"https:\/\/examples.javacodegeeks.com\/#organization"},"alternateName":"JCG","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/examples.javacodegeeks.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/examples.javacodegeeks.com\/#organization","name":"Exelixis Media P.C.","url":"https:\/\/examples.javacodegeeks.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2022\/06\/exelixis-logo.png","width":864,"height":246,"caption":"Exelixis Media P.C."},"image":{"@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/javacodegeeks","https:\/\/x.com\/javacodegeeks"]},{"@type":"Person","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/da48da5ffe2c95ab19f7b2162a3f30b2","name":"Shubham Aggarwal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/examples.javacodegeeks.com\/#\/schema\/person\/image\/","url":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg","contentUrl":"https:\/\/examples.javacodegeeks.com\/wp-content\/uploads\/2018\/09\/Shubham-Aggarwal_avatar_1536328481-96x96.jpeg","caption":"Shubham Aggarwal"},"description":"Shubham is a Java Backend and Data Analytics Engineer with more than 3 years of experience in building quality products with Spring Boot, MongoDB, Elasticsearch, MySQL, Docker, AWS, Git, PrestoDB tools and I have a deep knowledge and passion towards analytics, Micro-service based architecture, design patterns, antipatterns and software design thinking.","sameAs":["https:\/\/www.linkedin.com\/in\/sbmaggarwal\/","https:\/\/x.com\/sbmaggarwal"],"url":"https:\/\/examples.javacodegeeks.com\/author\/shubham-aggarwal\/"}]}},"_links":{"self":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/60680","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/users\/154"}],"replies":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/comments?post=60680"}],"version-history":[{"count":0,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/posts\/60680\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media\/1204"}],"wp:attachment":[{"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/media?parent=60680"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/categories?post=60680"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/examples.javacodegeeks.com\/wp-json\/wp\/v2\/tags?post=60680"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}