-
Notifications
You must be signed in to change notification settings - Fork 257
Full text search LINQ support #315
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,96 @@ | ||
| #region License | ||
| // The PostgreSQL License | ||
| // | ||
| // Copyright (C) 2016 The Npgsql Development Team | ||
| // | ||
| // Permission to use, copy, modify, and distribute this software and its | ||
| // documentation for any purpose, without fee, and without a written | ||
| // agreement is hereby granted, provided that the above copyright notice | ||
| // and this paragraph and the following two paragraphs appear in all copies. | ||
| // | ||
| // IN NO EVENT SHALL THE NPGSQL DEVELOPMENT TEAM BE LIABLE TO ANY PARTY | ||
| // FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES, | ||
| // INCLUDING LOST PROFITS, ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS | ||
| // DOCUMENTATION, EVEN IF THE NPGSQL DEVELOPMENT TEAM HAS BEEN ADVISED OF | ||
| // THE POSSIBILITY OF SUCH DAMAGE. | ||
| // | ||
| // THE NPGSQL DEVELOPMENT TEAM SPECIFICALLY DISCLAIMS ANY WARRANTIES, | ||
| // INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY | ||
| // AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE PROVIDED HEREUNDER IS | ||
| // ON AN "AS IS" BASIS, AND THE NPGSQL DEVELOPMENT TEAM HAS NO OBLIGATIONS | ||
| // TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR MODIFICATIONS. | ||
| #endregion | ||
|
|
||
| using System; | ||
| using System.Diagnostics.CodeAnalysis; | ||
| using NpgsqlTypes; | ||
|
|
||
| namespace Microsoft.EntityFrameworkCore | ||
| { | ||
| [SuppressMessage("ReSharper", "UnusedParameter.Global")] | ||
| public static class NpgsqlFullTextSearchDbFunctionsExtensions | ||
| { | ||
| /// <summary> | ||
| /// Reduce <paramref name="document" /> to tsvector. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-DOCUMENTS | ||
| /// </summary> | ||
| public static NpgsqlTsVector ToTsVector(this DbFunctions _, string document) => | ||
| throw new NotSupportedException(); | ||
|
|
||
| /// <summary> | ||
| /// Reduce <paramref name="document" /> to tsvector using the text search configuration specified | ||
| /// by <paramref name="config" />. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-DOCUMENTS | ||
| /// </summary> | ||
| public static NpgsqlTsVector ToTsVector(this DbFunctions _, string config, string document) => | ||
| throw new NotSupportedException(); | ||
|
|
||
| /// <summary> | ||
| /// Produce tsquery from <paramref name="query" /> ignoring punctuation. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery PlainToTsQuery(this DbFunctions _, string query) => | ||
| throw new NotSupportedException(); | ||
|
|
||
| /// <summary> | ||
| /// Produce tsquery from <paramref name="query" /> ignoring punctuation and using the text search | ||
| /// configuration specified by <paramref name="config" />. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery PlainToTsQuery(this DbFunctions _, string config, string query) => | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above (consider switching parameter order)
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my reply above.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| throw new NotSupportedException(); | ||
|
|
||
| /// <summary> | ||
| /// Produce tsquery that searches for a phrase from <paramref name="query" /> ignoring punctuation. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery PhraseToTsQuery(this DbFunctions _, string query) => | ||
| throw new NotSupportedException(); | ||
|
|
||
| /// <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" />. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery PhraseToTsQuery(this DbFunctions _, string config, string query) => | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. See my reply above.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| throw new NotSupportedException(); | ||
|
|
||
| /// <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. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery ToTsQuery(this DbFunctions _, string query) => throw new NotSupportedException(); | ||
|
|
||
| /// <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. | ||
| /// http://www.postgresql.org/docs/current/static/textsearch-controls.html#TEXTSEARCH-PARSING-QUERIES | ||
| /// </summary> | ||
| public static NpgsqlTsQuery ToTsQuery(this DbFunctions _, string config, string query) => | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. And again.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. OK |
||
| throw new NotSupportedException(); | ||
| } | ||
| } | ||
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.
Wouldn't it be a bit more idiomatic for document to be the first parameter here? I'm aware that this is the order in the PostgreSQL function, but we shouldn't be afraid to change that.
Uh oh!
There was an error while loading. Please reload this page.
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.
I thought about this, but since both parameter types are strings, I thought it will trip up people who know the full text functions and cause confusion and hate :-D, so I preferred sticking to the postgresql ordering as much as possible.
It also makes the method translation slightly simpler, but that's not an excuse I know :-)
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.
OK, makes sense.