/
NpgsqlFullTextSearchDbFunctionsExtensions.cs
152 lines (138 loc) · 7.7 KB
/
NpgsqlFullTextSearchDbFunctionsExtensions.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
using System.Diagnostics.CodeAnalysis;
// ReSharper disable once CheckNamespace
namespace Microsoft.EntityFrameworkCore;
/// <summary>
/// Provides CLR methods that get translated to database functions when used in LINQ to Entities queries.
/// The methods on this class are accessed via <see cref="EF.Functions" />.
/// </summary>
/// <remarks>
/// See <see href="https://aka.ms/efcore-docs-database-functions">Database functions</see>.
/// </remarks>
[SuppressMessage("ReSharper", "UnusedParameter.Global")]
public static class NpgsqlFullTextSearchDbFunctionsExtensions
{
/// <summary>
/// Convert <paramref name="lexemes" /> to a tsvector.
/// </summary>
/// <remarks>
/// https://www.postgresql.org/docs/current/static/functions-textsearch.html
/// </remarks>
public static NpgsqlTsVector ArrayToTsVector(this DbFunctions _, string[] lexemes)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ArrayToTsVector)));
/// <summary>
/// Reduce <paramref name="document" /> to tsvector.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-DOCUMENTS
/// </remarks>
public static NpgsqlTsVector ToTsVector(this DbFunctions _, string document)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTsVector)));
/// <summary>
/// Reduce <paramref name="document" /> to tsvector using the text search configuration specified
/// by <paramref name="config" />.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-DOCUMENTS
/// </remarks>
public static NpgsqlTsVector ToTsVector(this DbFunctions _, [NotParameterized] string config, string document)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTsVector)));
/// <summary>
/// Produce tsquery from <paramref name="query" /> ignoring punctuation.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery PlainToTsQuery(this DbFunctions _, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(PlainToTsQuery)));
/// <summary>
/// Produce tsquery from <paramref name="query" /> ignoring punctuation and using the text search
/// configuration specified by <paramref name="config" />.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery PlainToTsQuery(this DbFunctions _, [NotParameterized] string config, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(PlainToTsQuery)));
/// <summary>
/// Produce tsquery that searches for a phrase from <paramref name="query" /> ignoring punctuation.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery PhraseToTsQuery(this DbFunctions _, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(PhraseToTsQuery)));
/// <summary>
/// Produce tsquery that searches for a phrase from <paramref name="query" /> ignoring punctuation
/// and using the text search configuration specified by <paramref name="config" />.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery PhraseToTsQuery(this DbFunctions _, [NotParameterized] string config, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(PhraseToTsQuery)));
/// <summary>
/// Normalize words in <paramref name="query" /> and convert to tsquery. If your input
/// contains punctuation that should not be treated as text search operators, use
/// <see cref="PlainToTsQuery(DbFunctions, string)" /> instead.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery ToTsQuery(this DbFunctions _, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTsQuery)));
/// <summary>
/// Normalize words in <paramref name="query" /> and convert to tsquery using the text search
/// configuration specified by <paramref name="config" />. If your input contains punctuation
/// that should not be treated as text search operators, use
/// <see cref="PlainToTsQuery(DbFunctions, string, string)" /> instead.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery ToTsQuery(this DbFunctions _, [NotParameterized] string config, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(ToTsQuery)));
/// <summary>
/// Convert <paramref name="query" /> tsquery using the simplified websearch syntax.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery WebSearchToTsQuery(this DbFunctions _, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(WebSearchToTsQuery)));
/// <summary>
/// Convert <paramref name="query" /> tsquery using the simplified websearch syntax and the text
/// search configuration specified by <paramref name="config" />.
/// </summary>
/// <remarks>
/// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES
/// </remarks>
public static NpgsqlTsQuery WebSearchToTsQuery(this DbFunctions _, [NotParameterized] string config, string query)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(WebSearchToTsQuery)));
/// <summary>
/// Returns a new string that removes diacritics from characters in the given <paramref name="text" />.
/// </summary>
/// <param name="_">The <see cref="DbFunctions"/> instance.</param>
/// <param name="regDictionary">A specific text search dictionary.</param>
/// <param name="text">The text to remove the diacritics.</param>
/// <remarks>
/// <para>The method call is translated to <c>unaccent(regdictionary, text)</c>.</para>
///
/// See https://www.postgresql.org/docs/current/unaccent.html.
/// </remarks>
/// <returns>A string without diacritics.</returns>
public static string Unaccent(this DbFunctions _, string regDictionary, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Unaccent)));
/// <summary>
/// Returns a new string that removes diacritics from characters in the given <paramref name="text" />.
/// </summary>
/// <param name="_">The <see cref="DbFunctions"/> instance.</param>
/// <param name="text">The text to remove the diacritics.</param>
/// <remarks>
/// <para>The method call is translated to <c>unaccent(text)</c>.</para>
///
/// See https://www.postgresql.org/docs/current/unaccent.html.
/// </remarks>
/// <returns>A string without diacritics.</returns>
public static string Unaccent(this DbFunctions _, string text)
=> throw new InvalidOperationException(CoreStrings.FunctionOnClient(nameof(Unaccent)));
}