Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 12 additions & 12 deletions entity-framework/core/providers/sql-server/full-text-search.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,23 @@ protected override void OnModelCreating(ModelBuilder modelBuilder)

modelBuilder.Entity<Article>()
.HasFullTextIndex(a => a.Contents)
.HasKeyIndex("PK_Articles")
.OnCatalog("ftCatalog");
.UseKeyIndex("PK_Articles")
.UseCatalog("ftCatalog");
}
```

The `HasKeyIndex()` method specifies the unique, non-nullable, single-column index used as the full-text key for the table (typically the primary key index). `OnCatalog()` assigns the full-text index to a specific catalog.
The `UseKeyIndex()` method specifies the unique, non-nullable, single-column index used as the full-text key for the table (typically the primary key index). `UseCatalog()` assigns the full-text index to a specific catalog.

You can also configure multiple columns and additional options such as per-column languages and change tracking:

```csharp
modelBuilder.Entity<Article>()
.HasFullTextIndex(a => new { a.Title, a.Contents })
.HasKeyIndex("PK_Articles")
.OnCatalog("ftCatalog")
.WithChangeTracking(FullTextChangeTracking.Manual)
.HasLanguage("Title", "English")
.HasLanguage("Contents", "French");
.UseKeyIndex("PK_Articles")
.UseCatalog("ftCatalog")
.HasChangeTracking(FullTextChangeTracking.Manual)
.UseLanguage("Title", "English")
.UseLanguage("Contents", "French");
```

The full-text catalog can also be configured as the default catalog, and with accent sensitivity:
Expand Down Expand Up @@ -185,7 +185,7 @@ The above automatically searches across all columns registered for full-text sea
```csharp
var results = await context.Articles
.Join(
context.Articles.FreeTextTable<Article, int>(a => a.Contents, "veggies"),
context.Articles.FreeTextTable<Article, int>("veggies", a => a.Contents),
a => a.Id,
ftt => ftt.Key,
(a, ftt) => new { Article = a, ftt.Rank })
Expand All @@ -197,7 +197,7 @@ var results = await context.Articles

```csharp
var results = await context.Articles
.FreeTextTable(a => new { a.Title, a.Contents }, "veggies")
.FreeTextTable("veggies", a => new { a.Title, a.Contents })
.Select(r => new { Article = r.Value, Rank = r.Rank })
.OrderByDescending(r => r.Rank)
.ToListAsync();
Expand All @@ -224,7 +224,7 @@ Both table-valued functions support a `topN` parameter to limit the number of re

```csharp
var results = await context.Articles
.FreeTextTable(a => a.Contents, "veggies", topN: 10)
.FreeTextTable("veggies", a => a.Contents, topN: 10)
.Select(r => new { Article = r.Value, Rank = r.Rank })
.OrderByDescending(r => r.Rank)
.ToListAsync();
Expand All @@ -236,7 +236,7 @@ Both table-valued functions support specifying a language term for linguistic ma

```csharp
var results = await context.Articles
.FreeTextTable(a => a.Contents, "veggies", languageTerm: "English")
.FreeTextTable("veggies", a => a.Contents, languageTerm: "English")
.Select(r => new { Article = r.Value, Rank = r.Rank })
.ToListAsync();
```
Expand Down
8 changes: 4 additions & 4 deletions entity-framework/core/what-is-new/ef-core-11.0/whatsnew.md
Original file line number Diff line number Diff line change
Expand Up @@ -273,8 +273,8 @@ modelBuilder.HasFullTextCatalog("ftCatalog");

modelBuilder.Entity<Blog>()
.HasFullTextIndex(b => b.FullName)
.HasKeyIndex("PK_Blogs")
.OnCatalog("ftCatalog");
.UseKeyIndex("PK_Blogs")
.UseCatalog("ftCatalog");
```

This generates the following SQL in a migration:
Expand All @@ -297,14 +297,14 @@ However, SQL Server also has table-valued function versions of these functions,
```csharp
// Using FreeTextTable with a search query
var results = await context.Blogs
.FreeTextTable(b => b.FullName, "John")
.FreeTextTable("John", b => b.FullName)
.Select(r => new { Blog = r.Value, Rank = r.Rank })
.OrderByDescending(r => r.Rank)
.ToListAsync();

// Using ContainsTable with a search query
var results = await context.Blogs
.ContainsTable(b => b.FullName, "John")
.ContainsTable("John", b => b.FullName)
.Select(r => new { Blog = r.Value, Rank = r.Rank })
.OrderByDescending(r => r.Rank)
.ToListAsync();
Expand Down
Loading