PGroonga extension for Npgsql.EntityFrameworkCore.PostgreSQL (PostgreSQL / Npgsql Entity Framework Core provider). It enable the ability to do full text search, especially Chinese, Japanese, and so on, with EntityFramework Core, PostgreSQL and Groonga.
EF.Functions.Pgroonga*
only works with Npgsql.EntityFrameworkCore.PostgreSQL
>= 2.2.6 and >= 3.0.1 due to aspnet/EntityFrameworkCore#13454.
public class ApplicationDbContext : DbContext
{
// ...
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
// ...
modelBuilder.Entity<Post>()
.HasIndex(g => g.Content)
.HasMethod("pgroonga")
.HasOperators("pgroonga_varchar_full_text_search_ops_v2");
}
}
public class Startup
{
// ...
public void ConfigureServices(IServiceCollection services)
{
services.AddDbContextPool<ApplicationDbContext>(options =>
options.UseNpgsql(Configuration.GetConnectionString("DefaultConnection"),
builder => builder.UsePGroonga()));
// ...
}
}
var posts = await _dbContext.Posts.Where(g => g.Content.SimilarSearch(q))
.OrderByDescending(g => EF.Functions.PgroongaScore())
.ToArrayAsync();
For more information, see PGroongaLinqExtensions
and PGroongaDbFunctionsExtensions
.
- Operators
-
same as PostgreSQL standardLIKE
LIKE
-
same as PostgreSQL standardILIKE
ILIKE
- ==== pgroonga_xxx_full_text_search_ops[_v2] ====
-
&@
Match -
&@~
Query -
&@*
SimilarSearch -
&`
ScriptQuery -
&@|
MatchIn -
&@~|
QueryIn - ==== pgroonga_xxx_term_search_ops[_v2] ====
-
&^
PrefixSearch -
&^~
PrefixRkSearch -
&^|
PrefixSearchIn -
&^~|
PrefixRkSearchIn - ==== pgroonga_xxx_regexp_ops[_v2] ====
-
&~
RegexpMatch
-
- Functions
-
pgroonga_command
-
pgroonga_command_escape_value
-
pgroonga_escape
-
pgroonga_flush
-
pgroonga_highlight_html
-
pgroonga_is_writable
-
pgroonga_match_positions_byte
-
pgroonga_match_positions_character
-
pgroonga_normalize
-
pgroonga_query_escape
-
pgroonga_query_expand
-
pgroonga_query_extract_keywords
-
pgroonga_set_writable
-
pgroonga_score
-
pgroonga_snippet_html
-
pgroonga_table_name
-
pgroonga_wal_apply
-
pgroonga_wal_truncate
-
The MIT License
More info see LICENSE