Wyszukiwanie wykonania
Przeszukiwanie pełnego tekstu jest dostępne dla wystąpienie SQL Server jest przedstawiany w obiekty SMO przez FullTextService() obiekt. The FullTextService object resides under the Server object.Służy do zarządzania opcje konfiguracja dla Microsoft Usługa wyszukiwanie pełny. The FullTextCatalogCollection object belongs to the Database object and it is a kolekcja of FullTextCatalog objects that represent full-text catalogs defined for the database. Może istnieć tylko jeden indeks pełnotekstowy dla każdej tabela, w odróżnieniu od zwykłych indeksów.To jest reprezentowany przez FullTextIndexColumn obiekt w Table obiekt.
Aby utworzyć usługa przeszukiwanie pełnego tekstu, musisz mieć wykaz pełnotekstowy zdefiniowane w bazie danych i Indeks przeszukiwanie pełnego tekstu określonego w jednej z tabel w bazie danych.
Najpierw należy utworzyć wykaz pełnotekstowy do bazy danych, wywołując FullTextCatalog Konstruktor oraz określając nazwę katalogu. Następnie utwórz indeks pełnotekstowy wywoływania konstruktora i określając tabela, w którym ma zostać utworzony.Następnie można dodać indeks kolumna do indeksu całego tekstu przy użyciu FullTextIndexColumn obiekt i podanie nazwy kolumna w tabela. Następnie ustaw CatalogName() Właściwość do katalogu, które zostały utworzone. Wreszcie, wywołanie Create() metoda i utworzyć indeks pełnotekstowy dla wystąpienie SQL Server.
Przykład
Aby używać dostarczonych przykładów kodu źródłowego, należy wybrać środowisko, szablon oraz język programowania, które będą używane do tworzenia aplikacji.Aby uzyskać więcej informacji zobacz Jak Tworzenie obiektów SMO projektu Visual Basic w programie Visual Studio .NET lub Jak Tworzenie projektu programu Visual C# obiekty SMO w programie Visual Studio .NET.
Tworzenie usługa przeszukiwanie pełnego tekstu w języku Visual Basic
Ten przykładowy kod tworzy przeszukiwanie pełnego tekstu wykazu dla tabela ProductCategory przykładowej bazy danych AdventureWorks.Następnie tworzy przeszukiwanie pełnego tekstu indeksu kolumna Nazwa w tabela ProductCategory.przeszukiwanie pełnego tekstu Wymaga indeks jest już zdefiniowane na podstawie kolumna indeks unikatowy.
Tworzenie usługa przeszukiwanie pełnego tekstu w środowisku Visual C#
Ten przykładowy kod tworzy katalog wyszukiwania pełnotekstowego w tabela ProductCategory the AdventureWorks przykładowej bazy danych.Następnie tworzy przeszukiwanie pełnego tekstu indeksu kolumna Nazwa w tabela ProductCategory.przeszukiwanie pełnego tekstu Wymaga indeks jest już zdefiniowane na podstawie kolumna indeks unikatowy.
{
//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 varaible 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 arguements 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();
}