Full text search in natural language #6371

Closed
opened 2026-01-22 15:31:57 +01:00 by admin · 1 comment
Owner

Originally created by @o-alquimista on GitHub (Dec 17, 2019).

Q A
Version 2.7.0

Support Question

I use Symfony and Doctrine in my applications, and they have search functionality. Using full text index I can get results ordered by relevancy, so I decided to implement it.

I tried using the query builder and DQL, but it gives me an error saying it doesn't recognize the MATCH function. I didn't find anything about this in the documentation. All I could find online is people using plain SQL queries to achieve this type of search. In another source they said Doctrine doesn't support this because it is "vendor-specific", so I have to ask if that's true.

Right now I'm successfully performing the query with a prepared statement (without Doctrine):

SELECT * FROM product WHERE MATCH (name) AGAINST (:searchTerm IN NATURAL LANGUAGE MODE)

Is there a way to perform this query with Doctrine?

My database is MySQL 5.7.

Originally created by @o-alquimista on GitHub (Dec 17, 2019). <!-- Fill in the relevant information below to help triage your issue. --> | Q | A |------------ | ----- | Version | 2.7.0 <!-- Before asking question here, please try asking on Gitter or Slack first. Find out more about Doctrine support channels here: https://www.doctrine-project.org/community/ Keep in mind that GitHub is primarily an issue tracker. --> ### Support Question <!-- Describe the issue you are facing here. --> I use Symfony and Doctrine in my applications, and they have search functionality. Using [full text index](https://dev.mysql.com/doc/refman/5.7/en/fulltext-search.html) I can get results ordered by relevancy, so I decided to implement it. I tried using the query builder and DQL, but it gives me an error saying it doesn't recognize the MATCH function. I didn't find anything about this in the documentation. All I could find online is people using plain SQL queries to achieve this type of search. In another source they said Doctrine doesn't support this because it is "vendor-specific", so I have to ask if that's true. Right now I'm successfully performing the query with a prepared statement (without Doctrine): ``` SELECT * FROM product WHERE MATCH (name) AGAINST (:searchTerm IN NATURAL LANGUAGE MODE) ``` **Is there a way to perform this query with Doctrine?** My database is MySQL 5.7.
admin closed this issue 2026-01-22 15:31:57 +01:00
Author
Owner

@SenseException commented on GitHub (Dec 28, 2019):

There is no full-text search query in DQL for the ORM like the other source you mention is saying. Databases that are supporting full-text search are handling their features differently. While there is a standard for SQL, full-text was outsourced into the independent SQL/MM standard and most of the available RDBMS are to this day not on the same level as the defined standards, which makes it harder to implement database compatibility into ORM.

Your current solution seems to be a fitting one to your project. You could try to create yourself a custom DQL function for your needs, that is creating the MySQL syntax for your search though.

@SenseException commented on GitHub (Dec 28, 2019): There is no full-text search query in DQL for the ORM like the other source you mention is saying. Databases that are supporting full-text search are handling their features differently. While there is a standard for SQL, full-text was outsourced into the independent SQL/MM standard and most of the available RDBMS are to this day not on the same level as the defined standards, which makes it harder to implement database compatibility into ORM. Your current solution seems to be a fitting one to your project. You could try to create yourself a custom DQL function for your needs, that is creating the MySQL syntax for your search though.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: doctrine/archived-orm#6371