Class FullTextIndex
- Namespace
- YndigoBlue.Velocity.Model
- Assembly
- YndigoBlue.Velocity.dll
Represents a full-text index that enables advanced text search capabilities on table columns.
public class FullTextIndex : IEquatable<FullTextIndex>, IComparable<FullTextIndex>
- Inheritance
-
FullTextIndex
- Implements
Examples
Creating a full-text index on a single column:
Table articlesTable = schema.CreateTable("articles");
articlesTable.AddColumn("id", DataType.Integer);
articlesTable.AddColumn("title", DataType.VarChar, size: 200);
articlesTable.AddColumn("content", DataType.Clob);
// Create full-text index on content column
FullTextIndex contentIndex = articlesTable.AddFullTextIndex(
"ft_articles_content",
"content"
);
manager.BuildSchema(schema);
// SQL Server: CREATE FULLTEXT INDEX ON articles (content) KEY INDEX PK_articles
// MySQL: CREATE FULLTEXT INDEX ft_articles_content ON articles (content)
Creating a full-text index on multiple columns:
Table productsTable = schema.CreateTable("products");
productsTable.AddColumn("id", DataType.Integer);
productsTable.AddColumn("name", DataType.VarChar, size: 100);
productsTable.AddColumn("description", DataType.VarChar, size: 1000);
productsTable.AddColumn("features", DataType.Clob);
// Create full-text index across multiple columns
FullTextIndex productIndex = productsTable.AddFullTextIndex(
"ft_products_search",
"name",
"description",
"features"
);
manager.BuildSchema(schema);
// This allows searching across all three columns simultaneously
Searching with full-text index (database-specific):
// SQL Server - Using CONTAINS
Statement searchCondition = new Statement(
"CONTAINS(content, 'database OR performance')"
);
Query query = new Query();
query.AddFromItem(articlesTable);
query.AddSelectItem(articlesTable["id"]);
query.AddSelectItem(articlesTable["title"]);
query.AddWhereClause(new Filter(searchCondition));
IEnumerable<Result> results = manager.Retrieve(query);
Full-text index on blog posts:
Table postsTable = schema.CreateTable("posts");
postsTable.AddColumn("id", DataType.Integer);
postsTable.AddColumn("title", DataType.VarChar, size: 255);
postsTable.AddColumn("body", DataType.Clob);
postsTable.AddColumn("tags", DataType.VarChar, size: 500);
// Index title, body, and tags for comprehensive search
FullTextIndex postSearchIndex = postsTable.AddFullTextIndex(
"ft_posts_search",
"title",
"body",
"tags"
);
manager.BuildSchema(schema);
// Now users can search across titles, content, and tags efficiently
Remarks
WARNING: Full-text indexes are not available in the Community Edition of Velocity. They require the Full Edition.
Full-text indexes enable powerful text search features beyond simple LIKE queries, including:
- Searching for words or phrases within text columns
- Ranking search results by relevance
- Finding word variations (stemming)
- Searching across multiple text columns simultaneously
Full-text indexing is database-dependent and may not be supported on all database systems:
- SQL Server: Fully supported via CREATE FULLTEXT INDEX
- PostgreSQL: Supported via GIN/GiST indexes on tsvector columns
- MySQL: Supported via FULLTEXT indexes (InnoDB and MyISAM)
- Oracle: Supported via Oracle Text indexes
- SQLite, DB2, Teradata: Limited or no native support
Full-text indexes are created on tables using Table.AddFullTextIndex(string, string[]). The database creates the index when the schema is built with Engine.Manager.BuildSchema(Schema)\.
Performance Note: Full-text indexes can significantly improve search performance for text-heavy columns (like article content, descriptions, or comments), but they require additional storage space and can slow down INSERT/UPDATE operations.
Properties
- Columns
Gets the collection of column names included in this full-text index.
- IndexName
Gets or sets the name of the underlying index used for the full-text index.
- Name
Gets the name of the full-text index.
- SchemaName
Gets the name of the schema containing this full-text index's table.
- SchemaUpdate
Gets or sets whether this full-text index was created during a schema update operation.
- TableName
Gets the name of the table this full-text index belongs to.
Methods
- CompareTo(FullTextIndex)
Compares the current instance with another object of the same type and returns an integer that indicates whether the current instance precedes, follows, or occurs in the same position in the sort order as the other object.
- Equals(FullTextIndex)
Indicates whether the current object is equal to another object of the same type.