meilisearch / meilisearch

A lightning-fast search API that fits effortlessly into your apps, websites, and workflow
https://www.meilisearch.com
MIT License
47.26k stars 1.84k forks source link

Potential bug with array searchable attributes #4244

Open Fronix opened 11 months ago

Fronix commented 11 months ago

Describe the bug Original discord thread Was helping a person on how to make an array of object properties searchable and encountered an odd potential bug. Given a simple set of objects that includes a translations array with a title the text in the title can be searched if configured correctly in searchableAttributes but the word Ability gives no matches. All other words seem to be searchable.

To Reproduce Steps to reproduce the behavior:

  1. Download message.json
  2. Create a new index with default settings
  3. Add translations.title as the only searchable attribute
  4. Searching for to accept criticism gives matches
  5. Searching for criticism, gives matches
  6. Searching for Ability, gives no matches

Expected behavior Simply put, I'm expecting Ability to match several documents.

Screenshots image image image

Meilisearch version: v1.5.0

Additional information that may be relevant to the issue. Runs in docker

irevoire commented 11 months ago

I reproduced the bug on the latest main. It's really strange because no results are returned with "Ability" when this document exists:

{
      "id": "d81983f7-f7dc-4ddd-8fec-4e6cc39a7bd0",
      "translations": [
        {
          "id": "064ee085-cab1-44f4-8908-3ff52c1f677b",
          "languageCode": "EN",
          "title": "Ability to keep deadlines"
        },
        {
          "id": "ec40ab8f-ec31-4248-af78-aa9490f0f6e7",
          "languageCode": "HY",
          "title": "Ժամկետները պահպանելու ունակություն"
        }
      ],
      "type": "SOFT",
      "title": "Ability to keep deadlines"
    }

But I do get results when I look for any other word even when they're at the start of the document like "Constructive":

{
      "id": "eaa4e19d-adf4-49bf-adc3-1d98d6ed7e13",
      "translations": [
        {
          "id": "dff49658-5449-4c26-899a-8c0f3891560c",
          "languageCode": "EN",
          "title": "Constructive feedback giving"
        },
        {
          "id": "95cbebfb-0b4b-4c3e-9cb4-4c94867c125e",
          "languageCode": "HY",
          "title": "Կառուցողական հետադարձ կապի տրամադրում"
        }
      ],
      "type": "SOFT",
      "title": "Constructive feedback giving"
    }

The only difference I can see between Ability and any other word is that there are 8 documents starting with Ability without only one or two for every other word.

Fronix commented 11 months ago

I reproduced the bug on the latest main. It's really strange because no results are returned with "Ability" when this document exists:

{
      "id": "d81983f7-f7dc-4ddd-8fec-4e6cc39a7bd0",
      "translations": [
        {
          "id": "064ee085-cab1-44f4-8908-3ff52c1f677b",
          "languageCode": "EN",
          "title": "Ability to keep deadlines"
        },
        {
          "id": "ec40ab8f-ec31-4248-af78-aa9490f0f6e7",
          "languageCode": "HY",
          "title": "Ժամկետները պահպանելու ունակություն"
        }
      ],
      "type": "SOFT",
      "title": "Ability to keep deadlines"
    }

But I do get results when I look for any other word even when they're at the start of the document like "Constructive":

{
      "id": "eaa4e19d-adf4-49bf-adc3-1d98d6ed7e13",
      "translations": [
        {
          "id": "dff49658-5449-4c26-899a-8c0f3891560c",
          "languageCode": "EN",
          "title": "Constructive feedback giving"
        },
        {
          "id": "95cbebfb-0b4b-4c3e-9cb4-4c94867c125e",
          "languageCode": "HY",
          "title": "Կառուցողական հետադարձ կապի տրամադրում"
        }
      ],
      "type": "SOFT",
      "title": "Constructive feedback giving"
    }

The only difference I can see between Ability and any other word is that there are 8 documents starting with Ability without only one or two for every other word.

Yeah I can't make heads or tails of this, I also tried other words at the beginning and they worked fine but Ability doesn't.

jzabroski commented 10 months ago

If you point me to the area of code that likely does this, happy to spend time and debug it.

NarHakobyan commented 8 months ago

Sorting also works incorrectly

https://github.com/meilisearch/meilisearch/assets/1781506/c128fa72-8a24-499a-b704-f394fb191d43

irevoire commented 8 months ago

Hey @jzabroski,

Sorting also works incorrectly

Which version are you using? We fixed a bug in the latest version of meilisearch (v1.6.2)

NarHakobyan commented 8 months ago

Hey @jzabroski,

Sorting also works incorrectly

Which version are you using? We fixed a bug in the latest version of meilisearch (v1.6.2)

I'm using v1.6.0 version doesn't work in v1.6.2

irevoire commented 8 months ago

Hey @NarHakobyan,

After updating to the latest version, have you re-indexed your documents? Since the bug corrupts the database, you need to re-index everything to see the fix.

The easiest way to do that if you can’t clear your index and send back all your documents is to:

If you updated your version through a dump, none of this applies.

NarHakobyan commented 7 months ago

hi @irevoire,

Deleted all the settings (reseted to defaults) and Saved settings again, but it did not work

tested with latest version

{
    "commitSha": "0259ad6082cde748ac0478c03c49d8d9a1859e87",
    "commitDate": "2024-03-27T16:49:40.000000000Z",
    "pkgVersion": "1.7.4"
}
curquiza commented 1 month ago

Hello @Fronix

Do you still have the issue with v1.10.0?

Fronix commented 1 month ago

Currently not able to test but maybe https://github.com/NarHakobyan, who is the user I was helping with the issue can test?

Sent from Outlook for Androidhttps://aka.ms/AAb9ysg


From: Clémentine @.> Sent: Tuesday, September 17, 2024 10:23:52 AM To: meilisearch/meilisearch @.> Cc: Oscar Martin @.>; Mention @.> Subject: Re: [meilisearch/meilisearch] Potential bug with array searchable attributes (Issue #4244)

Hello @Fronixhttps://github.com/Fronix

Do you still have the issue with v1.10.0https://github.com/meilisearch/meilisearch/releases/tag/v1.10.0?

— Reply to this email directly, view it on GitHubhttps://github.com/meilisearch/meilisearch/issues/4244#issuecomment-2354865764, or unsubscribehttps://github.com/notifications/unsubscribe-auth/AAE2DDBW72RXLWJONRWM6DLZW7RJRAVCNFSM6AAAAABAD5YMDSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDGNJUHA3DKNZWGQ. You are receiving this because you were mentioned.Message ID: @.***>

jzabroski commented 1 month ago

After updating to the latest version, have you re-indexed your documents?

I suspect this is the key and why I initially offered my help to test this. I think the README should be clearer about refreshing indices when ugprading meilisearch. This is something I have discussed / hinted at in the past but would like to see movement on as I think it would help your core team members a lot. I am not a big brain, just somebody who likes quick wins.

curquiza commented 1 month ago

@jzabroski It's not common to have to reindex everything after upgrading Meilisearch. It's due to a specific bug, and we try to make clear in the related release notes. Sorry for the inconvenience.

Let us know @NarHakobyan