typesense icon indicating copy to clipboard operation
typesense copied to clipboard

Add `exact_match` option to schema's field parameters

Open jperezrealini opened this issue 2 years ago • 1 comments

Description:

Currently, the only way to achieve exact string matching in Typesense is by adding characters to symbols_to_index. However, this approach applies to all fields in the collection, which may not always be desirable.

Steps to Reproduce:

  1. Set a field of type string[] in your schema, such as sizes.
  2. Insert documents with values like ["11.5", "12", "4.5"] for the sizes field.
  3. Try filtering using the sizes field with the value 45.

Expected Behavior:

The filter should return documents that exactly match the value 45. No documents containing 4.5 should be included in the results.

Actual Behavior:

The filter returns documents that include 4.5, despite not being an exact match to 45.

image (3)

Proposed Solution:

Introduce an exact_match parameter to field definitions within the schema. When set to true, this parameter should enforce exact matching for the field during filtering operations.

Metadata:

  • Typesense Version: v27.0
  • OS: Cloud

jperezrealini avatar Sep 03 '24 19:09 jperezrealini

Also, I've noticed that the matching is case insensitive:

image

Looking at the docs (https://typesense.org/docs/27.0/api/search.html#filter-parameters):

"Exact vs Non-Exact Filtering: To match a string field's full value verbatim, you can use the := (exact match) operator. For eg: category := Shoe will match documents with category set as Shoe and not documents with a category field set as Shoe Rack."

This is kind of misleading, since filtering by shoe will match all of shoe, Shoe and SHOE

jperezrealini avatar Sep 06 '24 18:09 jperezrealini