Fixed: Magento 2 Full Text Search Not Working in Admin Grid
A full-text search, also known as keyword search, is a functionality that can produce more relevant results by scanning a huge number of fields in the Magento 2 admin grid. Adding the full-text search in Magento 2 grid can help the admin search more efficiently and faster.
If you are developing a custom Magento 2 extension or functionality, you may require to add search functionality to the grids to help the admin find specific data. However, sometimes, the Magento 2 full-text search functionality fails to work and may not produce proper results.
Here, in this blog post, I have provided a complete programmatic solution for the Magento 2 full-text search not working in the custom admin grid issue. You can use the code provided here to enable full-text search in Magento 2 admin grid.
Magento 2 Full Text Search Not Working in Admin Grid – How to Fix?
In order to add the full-text search functionality in Magento 2 admin grid, you need to create and add an index of the table.
It can be done by calling the addIndex() function in the \app\code\Vendor\Extension\Setup\InstallSchema.php file. Provided below is the complete code to make an index of the table and add the full-text search functionality in Magento 2 Admin grid:
1 2 3 4 5 6 7 |
$connection->addIndex( 'testtable', //table name'title', // index name [ 'title' // filed or column name ], \Magento\Framework\DB\Adapter\AdapterInterface::INDEX_TYPE_FULLTEXT //type of index ); |
Add the table name and column name in the above code to add full-text search in Magento 2 admin grid.
That’s it! 😃
I hope this Magento 2 solution will help you. Feel free to comment down below if you have any queries or doubts. I would be happy to help you.
Also, do not forget to share this amazing solution with your Magento friends.
Thanks for reading! 🙂
Related Reads:
Prev
Solved: Validate Class Not Found from Basename in Magento 2
How to Add or Remove Address Field from PDF in Magento 2
Next