Back to Devexpress

How to: Implement a Full-Text Search

xpo-3246-examples-how-to-implement-a-full-text-search.md

latest2.7 KB
Original Source

How to: Implement a Full-Text Search

  • Dec 28, 2022
  • 3 minutes to read

This example shows you how to create full-text queries against plain character-based data in SQL Server tables. Full-text queries can include words and phrases, or multiple forms of a word or phrase.

What Is a Full-Text Search?

A full-text search allows fast and flexible indexing for keyword-based query of text data stored in a Microsoft SQL Server database. In contrast to the LIKE predicate, which only works on character patterns, full-text queries perform linguistic searches against this data, by operating on words and phrases based on rules of a particular language.

Implementing a Full-Text Search

To implement a full-text search, do the following.

Using a Full-Text Search (a simple search)

To use a custom function operator in criteria you should first register it via the CriteriaOperator.RegisterCustomFunction method.

csharp
using DevExpress.Data.Filtering;

public class Program {
    //...
    public static void Main(string[] arguments) {
        CriteriaOperator.RegisterCustomFunction(new FullTextContainsFunction());
        //...
    }
}
vb
using DevExpress.Data.Filtering;

Public Class Program
    '...
    Public Shared Sub Main(ByVal arguments() As String)
        CriteriaOperator.RegisterCustomFunction(New FullTextContainsFunction())
        '...
    End Sub
End Class

After registering the custom operator, you can use it in your criteria.

csharp
private void Form1_Load(object sender, EventArgs e) {
    xpCollection1.Criteria = CriteriaOperator.Parse("FullTextContains(ProjectName, 'Business')");
}
vb
Private Sub Form1_Load(ByVal sender As Object, ByVal e As EventArgs)
    xpCollection1.Criteria = CriteriaOperator.Parse("FullTextContains(ProjectName, 'Business')")
End Sub

See Also

How to: Implement a Custom Criteria Language Function Operator