# Enable optimized text search on table fields
> APPLIES TO: Business Central 2024 release wave 2 (v25) and later.
Business Central includes an optimized text search feature on table fields, which uses the full-text search feature in SQL Server and Azure SQL Database databases. Optimized text search lets users and applications run full-text queries against character-based data in tables. This article explains how to allow optimized text search on table fields and how you can use it to filter data in AL.
In the client, optimized text search is used in various search functionalities, such as in the company-wide data search and on lists that include optimized text search fields, referred to as modern search. See Search for a record in company data</ui-search-data> and Search lists</ui-enter-criteria-filters#searching>. By enabling optimized text search on fields in extensions, you can significantly optimize data search in your AL code.
## Enable optimized text search on fields
To allow optimized text search on field, set the properties/devenv-optimizefortextsearch-property to true. The following example shows how text search is allowed on the field level:
```al
table 50100 Address
{
    Caption = 'Sample table';

    fields
    {
        field(1; Address; Text[50])
        {
            Caption = 'Address retrieved by Service';
            OptimizeForTextSearch = true;
        }
        field(2; Locality; Text[30])
        {
            Caption = 'Locality retrieved by Service';
            OptimizeForTextSearch = true;
        }
        field(3; "Town/City"; Text[30])
        {
            Caption = 'Town/City retrieved by Service';
            OptimizeForTextSearch = true;
        }
        field(4; County; Text[30])
        {
            Caption = 'County retrieved by Service';
            OptimizeForTextSearch = true;
        }
        field(5; IsValidated; Boolean)
        {
            Caption = 'Address validated yet?';
        }
    }
```
You can use the OptimizedForTextSearch property on the Field virtual table. You can also use the methods-auto/fieldref/fieldref-isoptimizedfortextsearch-method on FieldRef type variables of the FieldRef data type.
## Filter syntax for optimized text search
To use optimized text search in AL, you can add the `&&` operator when setting a filter, as illustrated in the following example:
```al
// Optimized text search without wildcard
Rec.SetFilter(Rec.Field, '&&' + SearchString);
```
You can also include wildcards in full-text search by adding the `*` symbol to the search clause as illustrated in the following example:
```al
// Optimized text search with wildcard
Rec.SetFilter(Rec.Field, '&&' + SearchString + '*' );
```
## Optimized text search semantics
Optimized text search differs from the traditional wildcard search using the '*' symbol in the following ways:
 Optimized text search is always case insensitive, where wildcard search is case sensitive unless either the dataset collation is insensitive or the `@` operator is prefixed.
 Optimized text search is always accent insensitive, where wildcard search is accent sensitive unless either the dataset collation is insensitive or the `@` operator is prefixed.
 Optimized text search looks for words within fields, where wildcard search looks for letters within fields. That means full-text search can find words or prefixes of words within a field, but wildcard search can find arbitrary substrings within words. Learn more in the following example.
### Example
Consider a database that includes the item `london swivel chair`. The following table demonstrates different queries on the item and indicates whether there's a match.
Query|Match
-|:-:
`*swivel*`|Yes
`&&swivel`|Yes
`*swiv*`|Yes
`&&swiv`|No
`&&swiv*`|Yes
`*hair*`|Yes
`&&hair`|No
`&&hair*`|No
## Install full-text search on the database (on-premises only)
To support optimized text search in Business Central on-premises, the SQL Server instance must include the full-text search feature.
The SQL server instance that hosts your Business Central database must include the Full-text and Semantic Extractions for Search feature. The version 25 Microsoft base application requires this feature; however, it isn't installed by default.
1. To verify whether full-text search is installed:
  Using Transactional-SQL
   Execute the following query on the SQL database instance:
   ```tsql
   SELECT FULLTEXTSERVICEPROPERTY('IsFullTextInstalled') AS IsFullTextInstalled;
   ```
   If the query returns `0`, then full-text search isn't installed; if `1`, then it's installed.
  Using SQL Server Management Studio
   In Object Explorer, right-click a server instance, select Properties, then select Advanced. If the Default Full-Text Language property is present, then full-text search is installed; otherwise, it isn't.
 See Viewing or Changing Server Properties for Full-Text Search<https://learn.microsoft.com/sql/relational-databases/search/manage-and-monitor-full-text-search-for-a-server-instance>
2. To install full-text search, add it as a feature by using the SQL Server Installation Center.
 You need to access the installation media or folder for your SQL Server version, and then run set.exe to start the SQL Server Installation Center. Follow the instructions at https://learn.microsoft.com/sql/database-engine/install-windows/add-features-to-an-instance-of-sql-server-setup. When you get to the Feature Selection page, choose Full-text and Semantic Extractions for Search.
> TIP
> If you're using SQL Server 2019 Express, you can download the installation media from Microsoft Download Center<https://www.microsoft.com/en-US/download/details.aspx?id=101064>.
## Related information
properties/devenv-optimizefortextsearch-property
IsOptimizeForTextSearch method<methods-auto/fieldref/fieldref-isoptimizedfortextsearch-method>
devenv-table-object
devenv-tables-overview
Full-text search in SQL<https://learn.microsoft.com/sql/relational-databases/search/full-text-search>

Copyright (c) Microsoft Corporation. CC BY 4.0, https://creativecommons.org/licenses/by/4.0/; code samples MIT. From https://learn.microsoft.com/en-us/dynamics365/business-central/dev-itpro/developer/devenv-table-field-text-search, MicrosoftDocs/dynamics365smb-devitpro-pb at 828b6ee (2026-11-19). Changed: includes filled in, links to this site, and for agents shortened without dropping a fact. https://jonas-paprotka.de/docs/dev-itpro/developer/devenv-table-field-text-search/
