Jegyzet
Az oldalhoz való hozzáférés engedélyezést igényel. Próbálhatod be jelentkezni vagy könyvtárat váltani.
Az oldalhoz való hozzáférés engedélyezést igényel. Megpróbálhatod a könyvtár váltását.
A következőkre vonatkozik:SQL Server
Azure SQL Database
Azure SQL Managed Instance
Azure Synapse Analytics
SQL-adatbázis a Microsoft Fabricben
A teljes szöveges keresés az SQL Server példányonként érhető el, és az objektum SMO-ban jeleníti meg FullTextService . Az FullTextService objektum a Kiszolgáló objektum alatt található. A Microsoft Full Text Search szolgáltatás konfigurációs beállításainak kezelésére szolgál. Az FullTextCatalogCollection objektum az Database objektumhoz tartozik, és olyan objektumok gyűjteménye FullTextCatalog , amelyek az adatbázishoz definiált teljes szöveges katalógusokat jelölik. Minden táblához csak egy teljes szöveges index definiálható, a normál indexekkel ellentétben. Ezt egy objektum jelöli FullTextIndexColumn az Table objektumban.
Teljes szöveges keresési szolgáltatás létrehozásához egy teljes szöveges katalógust kell definiálnia az adatbázisban, és egy teljes szöveges keresési indexet kell meghatároznia az adatbázis egyik tábláján.
Először hozzon létre egy teljes szöveges katalógust az adatbázisban a FullTextCatalog konstruktor meghívásával és a katalógus nevének megadásával. Ezután hozza létre a teljes szöveges indexet a konstruktor meghívásával, és adja meg azt a táblát, amelyen létre kívánja hozni. Ezután hozzáadhat indexoszlopokat a teljes szöveges indexhez az FullTextIndexColumn objektum használatával, és megadhatja az oszlop nevét a táblában. Ezután állítsa a tulajdonságot CatalogName a létrehozott katalógusra. Végül hívja meg a metódust Create , és hozza létre a teljes szöveges indexet az SQL Server példányán.
Example
A megadott kód példájának használatához ki kell választania a programozási környezetet, a programozási sablont és azt a programozási nyelvet, amelyben létre szeretné hozni az alkalmazást. További információ: Visual C# SMO-projekt létrehozása a Visual Studio .NET-.
Full-Text Search Service létrehozása a Visual Basicben
Ez a kódpélda teljes szöveges keresési katalógust hoz létre a ProductCategory AdventureWorks2025 mintaadatbázis táblájához. Ezután létrehoz egy teljes szöveges keresési indexet a tábla Név oszlopában ProductCategory . A teljes szöveges keresési indexhez szükség van egy egyedi indexre, amely már definiálva van az oszlopban.
' compile with:
' /r:Microsoft.SqlServer.SqlEnum.dll
' /r:Microsoft.SqlServer.Smo.dll
' /r:Microsoft.SqlServer.ConnectionInfo.dll
' /r:Microsoft.SqlServer.Management.Sdk.Sfc.dll
Imports Microsoft.SqlServer.Management.Smo
Imports Microsoft.SqlServer.Management.Sdk.Sfc
Imports Microsoft.SqlServer.Management.Common
Public Class A
Public Shared Sub Main()
' Connect to the local, default instance of SQL Server.
Dim srv As Server = Nothing
srv = New Server()
' Reference the AdventureWorks database.
Dim db As Database = Nothing
db = srv.Databases("AdventureWorks")
' Reference the ProductCategory table.
Dim tb As Table = Nothing
tb = db.Tables("ProductCategory", "Production")
' Define a FullTextCatalog object variable by specifying the parent database and name arguments in the constructor.
Dim ftc As FullTextCatalog = Nothing
ftc = New FullTextCatalog(db, "Test_Catalog")
ftc.IsDefault = True
' Create the Full-Text Search catalog on the instance of SQL Server.
ftc.Create()
' Define a FullTextIndex object variable by supplying the parent table argument in the constructor.
Dim fti As FullTextIndex = Nothing
fti = New FullTextIndex(tb)
' Define a FullTextIndexColumn object variable by supplying the parent index and column name arguments in the constructor.
Dim ftic As FullTextIndexColumn = Nothing
ftic = New FullTextIndexColumn(fti, "Name")
' Add the indexed column to the index.
fti.IndexedColumns.Add(ftic)
fti.ChangeTracking = ChangeTracking.Automatic
' Specify the unique index on the table that is required by the Full Text Search index.
fti.UniqueIndexName = "AK_ProductCategory_Name"
' Specify the catalog associated with the index.
fti.CatalogName = "Test_Catalog"
' Create the Full Text Search index on the instance of SQL Server.
fti.Create()
End Sub
End Class
Full-Text Keresési szolgáltatás létrehozása a Visual C-ben#
Ez a kódpélda teljes szöveges keresési katalógust hoz létre a ProductCategory AdventureWorks2025 mintaadatbázis táblájához. Ezután létrehoz egy teljes szöveges keresési indexet a tábla Név oszlopában ProductCategory . A teljes szöveges keresési indexhez szükség van egy egyedi indexre, amely már definiálva van az oszlopban.
// compile with:
// /r:Microsoft.SqlServer.SqlEnum.dll
// /r:Microsoft.SqlServer.Smo.dll
// /r:Microsoft.SqlServer.ConnectionInfo.dll
// /r:Microsoft.SqlServer.Management.Sdk.Sfc.dll
using Microsoft.SqlServer.Management.Smo;
using Microsoft.SqlServer.Management.Sdk.Sfc;
using Microsoft.SqlServer.Management.Common;
public class A {
public static void Main() {
// Connect to the local, default instance of SQL Server.
Server srv = default(Server);
srv = new Server();
// Reference the AdventureWorks database.
Database db = default(Database);
db = srv.Databases ["AdventureWorks"];
// Reference the ProductCategory table.
Table tb = default(Table);
tb = db.Tables["ProductCategory", "Production"];
// Define a FullTextCatalog object variable by specifying the parent database and name arguments in the constructor.
FullTextCatalog ftc = default(FullTextCatalog);
ftc = new FullTextCatalog(db, "Test_Catalog");
ftc.IsDefault = true;
// Create the Full-Text Search catalog on the instance of SQL Server.
ftc.Create();
// Define a FullTextIndex object variable by supplying the parent table argument in the constructor.
FullTextIndex fti = default(FullTextIndex);
fti = new FullTextIndex(tb);
// Define a FullTextIndexColumn object variable by supplying the parent index and column name arguments in the constructor.
FullTextIndexColumn ftic = default(FullTextIndexColumn);
ftic = new FullTextIndexColumn(fti, "Name");
// Add the indexed column to the index.
fti.IndexedColumns.Add(ftic);
fti.ChangeTracking = ChangeTracking.Automatic;
// Specify the unique index on the table that is required by the Full Text Search index.
fti.UniqueIndexName = "AK_ProductCategory_Name";
// Specify the catalog associated with the index.
fti.CatalogName = "Test_Catalog";
// Create the Full Text Search index on the instance of SQL Server.
fti.Create();
}
}
Full-Text Keresési szolgáltatás létrehozása a PowerShellben
Ez a kódpélda teljes szöveges keresési katalógust hoz létre a ProductCategory AdventureWorks2025 mintaadatbázis táblájához. Ezután létrehoz egy teljes szöveges keresési indexet a tábla Név oszlopában ProductCategory . A teljes szöveges keresési indexhez szükség van egy egyedi indexre, amely már definiálva van az oszlopban.
# Example of implementing a full text search on the default instance.
# Set the path context to the local, default instance of SQL Server and database tables
CD \sql\localhost\default\databases
$db = get-item AdventureWorks2022
CD AdventureWorks\tables
#Get a reference to the table
$tb = get-item Production.ProductCategory
# Define a FullTextCatalog object variable by specifying the parent database and name arguments in the constructor.
$ftc = New-Object -TypeName Microsoft.SqlServer.Management.SMO.FullTextCatalog -argumentlist $db, "Test_Catalog2"
$ftc.IsDefault = $true
# Create the Full Text Search catalog on the instance of SQL Server.
$ftc.Create()
# Define a FullTextIndex object variable by supplying the parent table argument in the constructor.
$fti = New-Object -TypeName Microsoft.SqlServer.Management.SMO.FullTextIndex -argumentlist $tb
# Define a FullTextIndexColumn object variable by supplying the parent index
# and column name arguments in the constructor.
$ftic = New-Object -TypeName Microsoft.SqlServer.Management.SMO.FullTextIndexColumn -argumentlist $fti, "Name"
# Add the indexed column to the index.
$fti.IndexedColumns.Add($ftic)
# Set change tracking
$fti.ChangeTracking = [Microsoft.SqlServer.Management.SMO.ChangeTracking]::Automatic
# Specify the unique index on the table that is required by the Full Text Search index.
$fti.UniqueIndexName = "AK_ProductCategory_Name"
# Specify the catalog associated with the index.
$fti.CatalogName = "Test_Catalog2"
# Create the Full Text Search Index
$fti.Create()