Skip to content

Attributes with typo tolerance disabled fail to match on exact query values #5836

@cklogs

Description

@cklogs

Describe the bug

If typo tolerance is turned off for an attribute, searching for an exact value fails to yield any results.

To Reproduce

  1. Stand-up a meilisearch docker instance.
version: "3.8"

services:
  meilisearch:
    image: getmeili/meilisearch:v1.12
    container_name: meilisearch
    ports:
      - "7701:7700"
    environment:
      MEILI_NO_ANALYTICS: "true"
      MEILI_ENV: "development"
    volumes:
      - meili_data:/meili_data

volumes:
  meili_data:
  1. Delete index (sanity check).
curl --location --request DELETE 'http://localhost:7701/indexes/widgets'
  1. Create index.
curl --location 'http://localhost:7701/indexes' \
--header 'Content-Type: application/json' \
--data '{
    "uid": "widgets",
    "primaryKey": "id"
}'
  1. Update searchable attributes.
curl --location --request PUT 'http://localhost:7701/indexes/widgets/settings/searchable-attributes' \
--header 'Content-Type: application/json' \
--data '[
    "serialNumber",
    "name"
]'
  1. Turn off typo tolerance on "serialNumber" attribute
curl --location --request PATCH 'http://localhost:7701/indexes/widgets/settings/typo-tolerance' \
--header 'Content-Type: application/json' \
--data '{
    "disableOnAttributes": ["serialNumber"]
}'
  1. Create 3 documents
curl --location 'http://localhost:7701/indexes/widgets/documents' \
--header 'Content-Type: application/json' \
--data '[
  {
    "id": 287947,
    "serialNumber": "SN1234",
    "name": "WIDGET ALPHA"
  },
  {
    "id": 287948,
    "serialNumber": "SN1235",
    "name": "WIDGET BETA"
  },
  {
    "id": 287949,
    "serialNumber": "SN1236",
    "name": "WIDGET GAMMA"
  }
]'

  1. Get documents, no query or filter values.
curl --location 'http://localhost:7701/indexes/widgets/search' \
--header 'Content-Type: application/json' \
--data '{
    "q": "",
    "offset": 0,
    "limit": 10
}'
Image
  1. [FAILS] Query for document using exact serialNumber value. Nothing is returned.
curl --location 'http://localhost:7701/indexes/widgets/search' \
--header 'Content-Type: application/json' \
--data '{
    "q": "SN1234",
    "offset": 0,
    "limit": 10
}'
Image

Additional notes

If the above reproduction steps are completed, but steps 5 and 6 have their order swapped, the issue cannot be seen.

Expected behavior

Attributes with typo tolerance turned off should be returned from search endpoint when exact match is provided in query.

Screenshots

See above.

Meilisearch version:
v1.12

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions