You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Fuzzy text search: support for Daitch-Mokotoff function #3524
There's probably a way to do this on my own until an official method exists. But the documentation feels a bit lacking around Array type mappings. Any help would be appreciated.
The daitch_mokotoff postgres function takes a text argument, and returns a text[].
publicstaticstring[]DaitchMokotoffSoundex(stringsource){thrownewInvalidOperationException($"{nameof(DaitchMokotoffSoundex)} should be performed on database");}publicstaticSqlExpressionTranslateDaitchMokotoffSoundex(IReadOnlyCollection<SqlExpression>args){// Get the source string parametervarsource=args.First();vardaitchMokotoffExpression=newSqlFunctionExpression("daitch_mokotoff",new[]{source},true,new[]{true},typeof(string[]),newNpgsqlArrayTypeMapping<string[],string[],string>(newNpgsqlStringTypeMapping("text",NpgsqlDbType.Text)));returndaitchMokotoffExpression;}
Any help with what I'm doing wrong would be deeply appreciated.
@profet23 the Daitch-Mokotoff function was added only recently to PG's fuzzystrmatch extensions (in PG 16), which is why there's no translation for it. You're welcome to submit a PR to add support for it, just like the EF.Functions.FuzzyStringMatchSoundex which is already supported.
Otherwise, in your code sample, rather than trying to instantiate NpgsqlArrayTypeMapping yourself, you can simply look up the type mapping for string[] via the type mapping source of the provider - that should be quite trivial and should work (check out other translators for examples).
BTW I'm also noticing that we don't actually have documentation for the fuzzy text search translations, submitted #405npgsql/doc#405 to fix this.
@profet23 the Daitch-Mokotoff function was added only recently to PG's fuzzystrmatch extensions (in PG 16), which is why there's no translation for it. You're welcome to submit a PR to add support for it, just like the EF.Functions.FuzzyStringMatchSoundex which is already supported.
Otherwise, in your code sample, rather than trying to instantiate NpgsqlArrayTypeMapping yourself, you can simply look up the type mapping for string[] via the type mapping source of the provider - that should be quite trivial and should work (check out other translators for examples).
BTW I'm also noticing that we don't actually have documentation for the fuzzy text search translations, submitted #405 to fix this.
publicstaticstring[]DaitchMokotoffSoundex(stringsource){thrownewInvalidOperationException($"{nameof(DaitchMokotoffSoundex)} should be performed on database");}publicstaticSqlExpressionTranslateDaitchMokotoffSoundex(IRelationalTypeMappingSourcetypeMappingSource,IReadOnlyCollection<SqlExpression>args){// Get the source string parametervarsource=args.First();vardaitchMokotoffExpression=newSqlFunctionExpression("daitch_mokotoff",new[]{source},true,new[]{true},typeof(string[]),typeMappingSource.FindMapping(typeof(string[])));returndaitchMokotoffExpression;}
Then I can execute the function and get a valid result array if I perform it as a select.
But if I try to do an operation on the result, say an Any operation or an Intersect operation, the expression fails to be translated with an exception:
could not be translated. Additional information: Translation of method 'System.Linq.Enumerable.Any' failed.
I understand this isn't a support forum. But any quick tips would be appreciated.
Sorry, wrong repo... The correct link is: npgsql/doc#405
But if I try to do an operation on the result, say an Any operation or an Intersect operation, the expression fails to be translated with an exception
Yeah, that's an unfortunate current limitation of EF itself - I opened dotnet/efcore#35980 to track this on the EF side. This is unrelated to Daitch-Mokotoff: it's a general limitation around composing LINQ operators on the return values of function calls in EF.
The below is an AI-generated analysis and may contain inaccuracies.
Classification: Feature request, not a regression. The requested built-in translation is absent from the current fuzzy-string-match API and its translator. PostgreSQL added daitch_mokotoff(text) -> text[] to fuzzystrmatch in PostgreSQL 16. This is PostgreSQL-specific provider functionality, so this is the appropriate repository. The issue type is confirmed as Feature; no bug repro or version-regression comparison was attempted for the missing feature.
Existing implementation:#3922 is open and explicitly fixes this issue, proposing EF.Functions.FuzzyStringMatchDaitchMokotoff(...) with an array return mapping and PostgreSQL 16+ support. Another implementation issue is unnecessary.
Related issues / duplicate search: No duplicate Daitch-Mokotoff feature request was found among open or closed issues in dotnet/efcore or npgsql/efcore.pg. The later Any/Intersect composition problem is separately tracked by the still-open dotnet/efcore#35980, which concerns composing LINQ operators over translated method results generally. It is related, not a duplicate of this request, and #3922 explicitly leaves it outside its scope.
The documentation gap mentioned in the discussion was addressed separately by the merged npgsql/doc#405; that documentation change did not add this translation. Keep this feature request open pending the implementation PR.
Activity
profet23 commentedon Apr 21, 2025
There's probably a way to do this on my own until an official method exists. But the documentation feels a bit lacking around Array type mappings. Any help would be appreciated.
The
daitch_mokotoffpostgres function takes a text argument, and returns a text[].This is not correct:
Any help with what I'm doing wrong would be deeply appreciated.
roji commentedon Apr 22, 2025
@profet23 the Daitch-Mokotoff function was added only recently to PG's fuzzystrmatch extensions (in PG 16), which is why there's no translation for it. You're welcome to submit a PR to add support for it, just like the EF.Functions.FuzzyStringMatchSoundex which is already supported.
Otherwise, in your code sample, rather than trying to instantiate NpgsqlArrayTypeMapping yourself, you can simply look up the type mapping for
string[]via the type mapping source of the provider - that should be quite trivial and should work (check out other translators for examples).BTW I'm also noticing that we don't actually have documentation for the fuzzy text search translations, submitted
#405npgsql/doc#405 to fix this.[-]Support for Daitch-Mokotoff function[/-][+]Fuzzy text search: support for Daitch-Mokotoff function[/+]profet23 commentedon Apr 22, 2025
Is that the correct issue number? "405" ?
profet23 commentedon Apr 22, 2025
@roji Thanks.
I'm REALLY close but I'm still having issues.
If I define my translation as:
Then I can execute the function and get a valid result array if I perform it as a select.
But if I try to do an operation on the result, say an
Anyoperation or anIntersectoperation, the expression fails to be translated with an exception:could not be translated. Additional information: Translation of method 'System.Linq.Enumerable.Any' failed.I understand this isn't a support forum. But any quick tips would be appreciated.
roji commentedon Apr 22, 2025
Sorry, wrong repo... The correct link is: npgsql/doc#405
Yeah, that's an unfortunate current limitation of EF itself - I opened dotnet/efcore#35980 to track this on the EF side. This is unrelated to Daitch-Mokotoff: it's a general limitation around composing LINQ operators on the return values of function calls in EF.
roji commentedon Oct 15, 2026
AI Triage
The below is an AI-generated analysis and may contain inaccuracies.
Classification: Feature request, not a regression. The requested built-in translation is absent from the current fuzzy-string-match API and its translator. PostgreSQL added
daitch_mokotoff(text) -> text[]tofuzzystrmatchin PostgreSQL 16. This is PostgreSQL-specific provider functionality, so this is the appropriate repository. The issue type is confirmed as Feature; no bug repro or version-regression comparison was attempted for the missing feature.Existing implementation: #3922 is open and explicitly fixes this issue, proposing
EF.Functions.FuzzyStringMatchDaitchMokotoff(...)with an array return mapping and PostgreSQL 16+ support. Another implementation issue is unnecessary.Related issues / duplicate search: No duplicate Daitch-Mokotoff feature request was found among open or closed issues in
dotnet/efcoreornpgsql/efcore.pg. The laterAny/Intersectcomposition problem is separately tracked by the still-open dotnet/efcore#35980, which concerns composing LINQ operators over translated method results generally. It is related, not a duplicate of this request, and #3922 explicitly leaves it outside its scope.The documentation gap mentioned in the discussion was addressed separately by the merged npgsql/doc#405; that documentation change did not add this translation. Keep this feature request open pending the implementation PR.
Add Daitch-Mokotoff fuzzy string matching support (npgsql#3922)