Vector search index queries with the `%` character not performing partial-string matches

When using the `LIKE` operator in vector search filters, specify the exact string you want to match

Written by Amruth Ashoka

Last published at: November 12th, 2024

Problem

While querying a vector search index, The LIKE operator fails to perform partial-string matches, but does perform complete-string matches. 

 

Cause

In vector search filters, the `%` character is treated as a literal character without any wildcard functionality. In SQL, the `%` character is used as a wildcard to match any sequence of characters. 

 

Solution

When using the LIKE operator in vector search filters, specify the exact string you want to match. Do not use the `%` character as a wildcard. 

 

Example

If you want to match any string that contains "value" as a substring, use the following vector search filter. 

`{"source": "value"}`

 

This will match any string that contains "value" as a substring, regardless of whether it is at the beginning, middle, or end of the string.