Chomik
Chomik

Reputation: 3

Full text seach in Doctrine using query builder with no result hits

Specs:

I've got a problem with full text search for SQL Server using Doctrine's query builder. I'm trying to use it with predicate 'FORMSOF' but as a result I get 0 hits from query.

I approached it in couple ways like:

$qb->where("CONTAINS(es.name, 'FORMSOF(INFLECTIONAL, :searchParam)')");

or

$formsof = new Func('FORMSOF', ['INFLECTIONAL', $searchParam]);
$containsFunc = new Func('CONTAINS', ['es.name', "'$formsof'"]);
$qb->add('where', $containsFunc);

I've also tried using DQL Custom Functions but with not results however it wasn't properly setup for sure because I was wondering if I should make 2 custom functions because of CONTAINS and FORMSOF or maybe one for CONTAINS or just FORMSOF?

The weird part is that native SQL query directly on the database works:

SELECT name
FROM cms_eservice ce
WHERE CONTAINS (name, 'FORMSOF(INFLECTIONAL, queryWord)'); 

And even native SQL using Doctrine however query builder approach does not.

And I want to stick with query builder because it's big query so it's easier to maintain that way.

My best shot is that 'FORMSOF' part is taken literally as a string by query builder. Just my assumption.

Upvotes: 0

Views: 371

Answers (0)

Related Questions