#community-help

Troubleshooting 'Contains' Match and Override Issues in Typesense

TLDR John sought assistance due to a seemingly faulty override in Typesense that failed to bring up a specific entry. Jason suggested troubleshooting steps, including trying a smaller record set and considering a server upgrade. A bug with 'contains' match appeared identified but not conclusively resolved.

Powered by Struct AI

1

May 11, 2022 (18 months ago)
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
10:25 PM
I have created the following override:
[0] => Array
                (
                    [excludes] => Array
                        (
                        )

                    [id] => bundle-COMP01_ART38169-3676
                    [includes] => Array
                        (
                            [0] => Array
                                (
                                    [id] => COMP01
                                    [position] => 1
                                )

                        )

                    [rule] => Array
                        (
                            [match] => contains
                            [query] => Final de tarde
                        )

                )

COMP01 is the id of an existing entry.

But when I search for "Final de tarde" the entry COMP01 does not appear.

Did I make a mistake somewhere?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:30 PM
Hmm, this should work...
10:30
Jason
10:30 PM
Could you try replicating this on a collection with a few records?
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
10:51 PM
I have other overrides, but all of them have empty [excludes]. This would mean that no interaction between them could cancel the appearance of COMP01, correct?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:52 PM
Correct...
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
10:52 PM
I will try to replicate on a small set.
May 12, 2022 (18 months ago)
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:24 PM
OK, I created a new collection called 'debug' for testing. It has more or less 150 entries and for each one 3 or 4 overrides.

Now, is there an easy way to query this collection (since I would not like to modify our production site for this test)?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:30 PM
If you're on Typesense Cloud, you could query from the dashboard...
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:30 PM
Yep, it still does not bring COMP01...
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:31 PM
Could you DM me your cluster ID?
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:34 PM
This is the relevant override
09:34
John
09:34 PM
Now, where do I see the linked document (which in this case would be COMP01)?
09:42
John
09:42 PM
I just created manually an equivalent override with the search query to curate being "chicken pox" and linked as well to COMP01. This one works...:thinking_face:
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:44 PM
Just realized that the Typesense Cloud UI for Overrides uses a feature that is only available in v0.22.2 and later of Typesense server...
09:44
Jason
09:44 PM
That's why the UI under "Pin Documents" is blank. It should have shown you the actual documents that are pinned
09:46
Jason
09:46 PM
That is a separate issues though... Overrides not being triggered is still strange. It could be a bug with how "contains" works in that version
09:46
Jason
09:46 PM
We did fix one related issue in the latest RC build of Typesense server
09:47
Jason
09:47 PM
I know we had a separate email thread going about updating your cluster to the latest RC. Could you implement the change needed so we can upgrade you to the latest version? We can then see if we can replicate this overrides issue on that build, and debug from there
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:49 PM
We have made the upgrade and decided to revert it as it we liked the search better on the current version...
09:49
John
09:49 PM
Now, another thing I noticed with my manually created example. If I search for "chicken pox" and I just add a space the override gets ignored... Isn't that weird
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:49 PM
That's because the override you added is an "exact" match override
09:50
Jason
09:50 PM
The other ones you had were "contains" match
09:50
Jason
09:50 PM
> We have made the upgrade and decided to revert it as it we liked the search better on the current version...
It was related to ID searches right? The solution for that is to index the ID in a new field and use that in query_by. In the latest version we've excluded ID from being searchable, that's why ID searches didn't return any results.
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:51 PM
No, ID searches were a small side unimportant issue...
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:52 PM
Oh I see, mind sharing more examples of searches that didn't surface the expected results in that email thread? I'd love to get to the bottom of those
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:52 PM
It was really a search results one. Since our entries are arts, people are searching more for concepts than actual well defined ideas. And we think the results were better before...
09:53
John
09:53 PM
It's not that the search results were irrelevant, they simply were better before...
09:54
John
09:54 PM
That's why I wondered about being able to configure this programatically... that way we could upgrade...
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:54 PM
> I'd love to get to the bottom of those
... because any fixes we do will only go into the latest release, so you would have to upgrade at some point. So I'd want to see how we can configure the search to rank results based on your preference even in the new version.

So if you're able to share some examples of search terms in that email thread, we can see how to configure the search appropriately.
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:55 PM
Now, returning to our tests in the debug collection: I changed from EXACT to CONTAINS and... it stopped including COMP01!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
09:55 PM
Yeah, so it looks like a bug with contains match in that version...
John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
09:56 PM
Except contains works for other overrides! That's the weird thing.
09:56
John
09:56 PM
Let me give you an example.
09:58
John
09:58 PM
This one is OK!
09:59
John
09:59 PM
(this one is in our 'arts' collection)
10:01
John
10:01 PM
Hey, but I saw just now, it looks like the match is on the ID of the document!
10:04
John
10:04 PM
OK, just found a dirty fix then. I just need to make the ID have the search term as well. In the 'debug' collection I updated my override to be 'test-override-chicken-pox'. And now it returns COMP01!
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
10:05 PM
Ha!! I'm really surprised this works 😅 😓

1

John
Photo of md5-7a0ab48aa8979a59e1d8c3919797c1f8
John
10:09 PM
Now, regarding "examples of search terms to configure the search appropriately" it will be hard, unless you would be able to create a copy of our data to a latest version cloud in a test account... Is this a possibility?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
11:31 PM
John If you can install Docker on your local machine, it's just a few commands to run Typesense locally: https://typesense.org/docs/guide/install-typesense.html#from-the-docker-image