-
Notifications
You must be signed in to change notification settings - Fork 461
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
FTS extensions #1649
Merged
Merged
FTS extensions #1649
Changes from all commits
Commits
Show all changes
29 commits
Select commit
Hold shift + click to select a range
edf4ff1
Fixes #386
MaceWindu 831adac
Merge branch 'master' into issue_386
sdanyliv ccfd43a
Refactored FreeTextTableExpressionAttribute. Added possibly to genera…
sdanyliv d4bf48d
Improve custom query generation. Added a lot of ways to create dynami…
sdanyliv 7a0970e
Merge remote-tracking branch 'origin/master' into issue_386
MaceWindu 231d163
Merge branch 'master' into issue_386
MaceWindu 96fa92b
fix tests build
MaceWindu 40b4ac4
Merge branch 'master' into issue_386
MaceWindu 4e37295
new FREETEXTTABLE extension, CONTAINSTABLE extension
MaceWindu fde7666
add more tests
MaceWindu 62699a5
FREETEXT predicate
MaceWindu a59a491
disable FTS T4 generation by default
MaceWindu 3033c6b
CONTAINS predicate (without PROPERTY support)
MaceWindu 1697caf
CONTAINS(PROPERTY) extension and parameters inlining tests
MaceWindu 1aa6115
SQLite FTS-related extensions part 1 (untested)
MaceWindu 7cb5c9c
SQLite FTS3/4/5 support (except commands)
MaceWindu 0c37411
SQLite FTS commands support
MaceWindu acd6cd6
mysql FTS extensions
MaceWindu 47d23bd
move mysql extensions to Sql.Ext.MySql() endpoint
MaceWindu 3456501
move sqlite extensions to sql.ext
MaceWindu 3f224ee
move sqlserver extensions to sql.ext, fix northwind script
MaceWindu c1cca63
update fts obsolete messages
MaceWindu 740b1ab
disable another test for netstandard1.6
MaceWindu f35fb8e
fix ITableMutable* implementation
MaceWindu d9b3efa
add tests failing over linqservice
MaceWindu 191427a
hide new extensions for now
MaceWindu 798669d
Merge branch 'master' into fts_extensions_v2
MaceWindu 5ce931f
serialize SqlField.Table for remote service
MaceWindu d6b9722
move test attribute to proper method
MaceWindu File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,119 @@ | ||
using LinqToDB.Expressions; | ||
using LinqToDB.Linq; | ||
using System; | ||
|
||
namespace LinqToDB.DataProvider.MySql | ||
{ | ||
public interface IMySqlExtensions | ||
{ | ||
} | ||
|
||
public static class MySqlExtensions | ||
{ | ||
public static IMySqlExtensions MySql(this Sql.ISqlExtension ext) => null; | ||
|
||
#region FTS | ||
class ModifierBuilder : Sql.IExtensionCallBuilder | ||
{ | ||
public void Build(Sql.ISqExtensionBuilder builder) | ||
{ | ||
var modifier = builder.GetValue<MatchModifier>("modifier"); | ||
|
||
switch (modifier) | ||
{ | ||
case MatchModifier.NaturalLanguage: | ||
// default modifier, no need to add it to SQL | ||
break; | ||
case MatchModifier.Boolean: | ||
builder.AddExpression("modifier", " IN BOOLEAN MODE"); | ||
break; | ||
case MatchModifier.WithQueryExpansion: | ||
// use short form without 'IN NATURAL LANGUAGE MODE' prefix | ||
builder.AddExpression("modifier", " WITH QUERY EXPANSION"); | ||
break; | ||
default: | ||
throw new ArgumentOutOfRangeException("modifier"); | ||
} | ||
} | ||
} | ||
|
||
/// <summary> | ||
/// Search modifier for MATCH AGAINST full-text search predicate. | ||
/// </summary> | ||
public enum MatchModifier | ||
{ | ||
/// <summary> | ||
/// Applies 'IN NATURAL LANGUAGE MODE' (default value) search modifier. | ||
/// </summary> | ||
NaturalLanguage, | ||
/// <summary> | ||
/// Applies 'IN BOOLEAN MODE' (default value) search modifier. | ||
/// </summary> | ||
Boolean, | ||
/// <summary> | ||
/// Applies 'IN NATURAL LANGUAGE MODE WITH QUERY EXPANSION'/'WITH QUERY EXPANSION' search modifier. | ||
/// </summary> | ||
WithQueryExpansion | ||
} | ||
|
||
/// <summary> | ||
/// Applies full-text search condition using MATCH AGAINST predicate against specified full-text columns using default mode (IN NATURAL LANGUAGE MODE). | ||
/// Example: MATCH(col1, col2) AGAINST('search query'). | ||
/// </summary> | ||
/// <param name="ext">Extension point.</param> | ||
/// <param name="search">Full-text search condition.</param> | ||
/// <param name="columns">Full-text columns that should be queried.</param> | ||
/// <returns>Returns <c>true</c> if full-text search found matching records.</returns> | ||
[Sql.Extension("MATCH({columns, ', '}) AGAINST ({search})", IsPredicate = true, ServerSideOnly = true)] | ||
public static bool Match(this IMySqlExtensions ext, [ExprParameter("search")] string search, [ExprParameter("columns")] params object[] columns) | ||
{ | ||
throw new LinqException($"'{nameof(Match)}' is server-side method."); | ||
} | ||
|
||
/// <summary> | ||
/// Calculates relevance of full-text search for current record using MATCH AGAINST predicate against specified full-text columns using default mode (IN NATURAL LANGUAGE MODE). | ||
/// Example: MATCH(col1, col2) AGAINST('search query'). | ||
/// </summary> | ||
/// <param name="ext">Extension point.</param> | ||
/// <param name="search">Full-text search condition.</param> | ||
/// <param name="columns">Full-text columns that should be queried.</param> | ||
/// <returns>Returns full-text search relevance value for current record.</returns> | ||
[Sql.Extension("MATCH({columns, ', '}) AGAINST ({search})", ServerSideOnly = true)] | ||
public static double MatchRelevance(this IMySqlExtensions ext, [ExprParameter("search")] string search, [ExprParameter("columns")] params object[] columns) | ||
{ | ||
throw new LinqException($"'{nameof(MatchRelevance)}' is server-side method."); | ||
} | ||
|
||
/// <summary> | ||
/// Applies full-text search condition using MATCH AGAINST predicate against specified full-text columns using specified search modifier. | ||
/// Example: MATCH(col1, col2) AGAINST('search query' MODIFIER). | ||
/// </summary> | ||
/// <param name="ext">Extension point.</param> | ||
/// <param name="modifier">Search modifier.</param> | ||
/// <param name="search">Full-text search condition.</param> | ||
/// <param name="columns">Full-text columns that should be queried.</param> | ||
/// <returns>Returns <c>true</c> if full-text search found matching records.</returns> | ||
[Sql.Extension("MATCH({columns, ', '}) AGAINST ({search}{modifier?})", IsPredicate = true, ServerSideOnly = true, BuilderType = typeof(ModifierBuilder))] | ||
public static bool Match(this IMySqlExtensions ext, [SqlQueryDependent] MatchModifier modifier, [ExprParameter("search")] string search, [ExprParameter("columns")] params object[] columns) | ||
{ | ||
throw new LinqException($"'{nameof(Match)}' is server-side method."); | ||
} | ||
|
||
/// <summary> | ||
/// Calculates relevance of full-text search for current record using MATCH AGAINST predicate against specified full-text columns using specified search modifier. | ||
/// Example: MATCH(col1, col2) AGAINST('search query' MODIFIER). | ||
/// </summary> | ||
/// <param name="ext">Extension point.</param> | ||
/// <param name="modifier">Search modifier.</param> | ||
/// <param name="search">Full-text search condition.</param> | ||
/// <param name="columns">Full-text columns that should be queried.</param> | ||
/// <returns>Returns full-text search relevance value for current record.</returns> | ||
[Sql.Extension("MATCH({columns, ', '}) AGAINST ({search}{modifier?})", ServerSideOnly = true, BuilderType = typeof(ModifierBuilder))] | ||
public static double MatchRelevance(this IMySqlExtensions ext, [SqlQueryDependent] MatchModifier modifier, [ExprParameter("search")] string search, [ExprParameter("columns")] params object[] columns) | ||
{ | ||
throw new LinqException($"'{nameof(MatchRelevance)}' is server-side method."); | ||
} | ||
|
||
#endregion | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is no one place. But name of parameter is not required - original parameter name will be used