---
schema_version: "1"
id: 408802af2520b3fa9f55879182f0ffdea5b719af045d45a2e4b07537457024f6
title: Hybrid Search Query Expressions
collection: admin
version: current
locale: en-us
portal_url: https://docs.salesforce.com/admin/current/en-us/data/264-0-0/c360_a_hybridsearch_query_expressions.md
canonical_url: https://help.salesforce.com/s/articleView?id=data.c360_a_hybridsearch_query_expressions.htm&release=264.0.0&type=5
source_site: help.salesforce.com
content_type: documentation
content_hash: a4990269592b39752c3246730654f75e8306e61ec012a3863e115e7eea72a3df
description: Enhance your hybrid search queries with pre-filtering fields and join expressions to access fields.
products:
  - Data 360
release: "264"
---
# Hybrid Search Query Expressions

Enhance your hybrid search queries with pre-filtering fields and join expressions to access fields.

## Filter Expressions in Hybrid Search

<table class="slds-table slds-table_bordered slds-max-medium-table_stacked slds-m-bottom_small ">
        <colgroup>
          <col style="width:24.509803921568626%">
          <col style="width:50.98039215686274%">
          <col style="width:24.509803921568626%">
        </colgroup>
        <thead class="slds-text-title_caps ">
          <tr class="">
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d96159e43"> Expressions Types</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d96159e46">Examples</th>
            <th scope="col" class="slds-cell-wrap" style="vertical-align:top;" id="d96159e49">Notes</th>
          </tr>
        </thead>
        <tbody>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Expressions with NOT, IN, AND, OR operators</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>strField1 != 'v1' and
strField2 = 'v2' and
(strField3 = 'v3' or
strField4 not in ('a', 'b', 'c') or
strField5 in ('a', 'b', 'c')
) and
strField6='v6'
</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">You can combine individual filters using the logical <code>and</code> and
              <code>or</code> operators.
            </td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Simple pre-filter expression in a SQL expression</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from 
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'RecordId__c=''1c1c533c-1bc0-40cb-8bd8-f4b6e6e101b7''',
            10)
        )</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">When the pre-filter condition is part of the SQL expression the quotes in the
              filter expression have to be escaped by doubling them.</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Complex pre-filter expression in a SQL expression</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'strField1 != ''v1'' and strField2 = ''v2'' and 
            (strField3 = ''v3'' or
            strField4 not in (''a'', ''b'', ''c'') or
            strField5 in (''a'', ''b'', ''c'')) and
            strField6=''v6''', 10)</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">When the pre-filter condition is part of the SQL expression the quotes in the
              filter expression have to be escaped by doubling them.</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Pre-filtering on a field that is of Number data type</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from 
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'NumField=2',
            10)</code></pre>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from 
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'NumField&gt;2',
            10)</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">—</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Pre-filtering on a field that is of Date/DateTime data type with the standard
              (Z) offset</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'DateTimeTypeWithTimezone=2024-05-08T15:28:07.000Z',
            10)</code></pre>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x" id="c360_a_hybridsearch_query_expressions__codeblock_cmm_tkd_rdc"><a name="c360_a_hybridsearch_query_expressions__codeblock_cmm_tkd_rdc"><!-- --></a><code>select * from
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'DateTimeTypeWithTimezone&gt;=2024-05-08T15:28:07.000Z',
            10)</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">The date value doesn’t have to be surrounded by two single quotes (as vector
              search does).</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Pre-filtering on a field that is of Date/DateTime data type with a custom
              offset</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from (
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'DateTimeTypeWithTimezone=2024-05-08T15:28:07.000-08:30',
            10)</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">The date value doesn’t have to be surrounded by two single quotes (as vector
              search does).</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Pre-filtering on a field with Date only</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from 
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'DateType=2024-05-08',
            10)</code></pre>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x" id="c360_a_hybridsearch_query_expressions__codeblock_zy5_skd_rdc"><a name="c360_a_hybridsearch_query_expressions__codeblock_zy5_skd_rdc"><!-- --></a><code>select * from 
        hybrid_search(
            TABLE('some_VDMO'),
            'some_search_text',
            'DateType&lt;2024-05-08',
            10)</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">The date value doesn’t have to be surrounded by two single quotes (as vector
              search does).</td>

          </tr>
          <tr class="">
            <td data-label="Expressions Types" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e43 ">Pre-filtering on a field which is of string data type with the LIKE
              operator.</td>

            <td data-label="Examples" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e46 ">
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>select * from
hybrid_search(
TABLE('some_VDMO'),
'some_search_text',
'StrField LIKE ''prefix%''',
10)
</code></pre>
            </td>

            <td data-label="Notes" class="slds-cell-wrap" style="vertical-align:top;" headers="d96159e49 ">
              <p>The LIKE operator must be used with a value with a single trailing wildcard
                character (%). The following are examples of invalid LIKE
                filters.</p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>'StrField LIKE ''%prefix%'''
'StrField LIKE ''%prefix'''
'StrField LIKE ''prefix%suffix'''
</code></pre>
              <p>The LIKE operator doesn't support the following characters, <code>: ^
                  { } [ ] ( ).</code> For example, the expression
              </p>
              <pre class="line-numbers slds-box slds-box_x-small slds-theme_shade slds-m-top_medium slds-m-bottom_medium slds-scrollable_x"><code>Field__c LIKE 'https:%'</code></pre>
              <p style="margin-bottom:0;">, is invalid because it contains a
                colon (:).</p>
            </td>

          </tr>
        </tbody>
      </table>

## Case Sensitivity on Pre-filtering Fields

Names of pre-filtering fields are case insensitive. For example, if the name of a field is `My_Column_c` , a filter expression with `my_column_c` correctly references that field. However, case matters for values used within filters. If the field has a value `SomeValue,`  the filter expression `My_Column_c='somevalue'` or `My_Column_c='SOMEVALUE'` results in a no-match—only the expression `My_Column_c='SomeValue'` matches that record.

## Default Pre-filtering Fields

The field `DataSource__c` from the chunk data model object (CDMO) is a default pre-filtering field. It is always available in pre-filtering queries.

## Pre-filtering Values for Objects in 1:N Relationships

When creating a search index, you can index only one pre-filtering value.

Consider this example. You create a search index in which the indexed chunk data model object (CDMO) is in a 1:N relationship with related records from which a pre-filtering value is extracted. In the relationship, the CDMO `{"chunkId":"1"}` matches both `{"filterRecordId"="123": "filterValue": "tag1"}` and `{"filterRecordId"="123": "filterValue": "tag2”}`.

Data 360 indexes only one of these filtered values for retrieval, and there’s no guarantee which one is indexed. For example, Data 360 may index`{"chunkId":"1", "filterValue":"tag1"}` or `{"chunkId":"1", "filterValue":"tag2"}` but not `{"chunkId":"1", "filterValue":["tag1", "tag2”]}`.

## Join Expressions in Hybrid Search

Include joins to access fields from both the Chunk DMO and Search Index DMO associated with the index.

```
SELECT
  src.ArticleNumber__c,
  hsearch.hybrid_score__c
FROM
  hybrid_search(	
    TABLE(Knowledge_index__dlm),
    'DataWedge Decode Volume',
    '',
    10
  ) hsearch
  join Knowledge_chunk__dlm chnk 
on hsearch.SourceRecordId__c = chnk.RecordId__c
  join Knowledge_kav_Home__dlm src 
on chnk.SourceRecordId__c = src.Id__c
```