'How do you do fulltext search add two field with Entity Framework Core?

If only one field is searched, it can be successful. But not two.

var results = db.tables
    .Where(x => EF.Functions.Match(x.Title, "search text",MySqlMatchSearchMode.Boolean));

I want to get sql syntax result.

select * from articles 
where match(`title`) against('葡萄牙') > 0;

Below is the result I want to achieve.

var results = db.tables
    .Where(x => EF.Functions.Match(x.Title+x.ArticleContent, "search text"));

I want to get sql syntax result.

select * from articles 
where match(`title`,`article_content`) against('葡萄牙') > 0;

Error : MySqlConnector.MySqlException (0x80004005): You have an error in your SQL syntax; check the manual that corresponds to your MariaDB server version for the right syntax to use near '(s.title, COALESCE(s.article_content, ''))) AGAINST ('葡萄牙' IN BOOL...' at line 3



Solution 1:[1]

Because I found the answer, share the answer URL : <https://github.com/PomeloFoundation/Pomelo.EntityFrameworkCore.MySql/blob/f4b1ab9497743db5a395a36340515b3d3fc28e3c/test/EFCore.MySql.FunctionalTests/Query/MatchQueryMySqlTest.cs >

var results = db.tables
    .Where(x => EF.Functions.Match(new [] {x.Title,x.ArticleContent}, "search text"));

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Jimmy