Back

Not getting search result

  • 1
  • Databases
  • Web
  • Cloud
-N I N J A-
14 Dec, 2023, 11:02

I need to search: When I was young, to get that doc

TL;DR
The user is having issues with getting search results in an app using Appwrite. They mention stop words and the length of search terms affecting the results. They also ask how to ignore stop words in Appwrite. In response, a link is provided for more information on stop words in MySQL. It is mentioned that some words are ignored because they are stop words or too short. The user confirms a problem with certain keywords not producing results. The solution provided is to search using individual words rather than a full phrase.
Ernest
14 Dec, 2023, 11:28

Did your search include the comma? Also, with FTS the matching is done by words and passing in "When I was" matches any document containing any of the words (i.e When, I and was) in the relevant attribute. Partial matches only works if there's only one word in the search term matching any document with any word starting with the query word. E.g. ID | name 1 | Jane Doe 2 | John Doe 3 | Janet Armstrong

Query.search('name', "Jane") => Matches 1,3 (matches both Jane and Janet becuase there is a single word in the query thus partial prefix match works) Query.search('name', "Janet Doe") => Matches 1,2,3 (1,2 matched by Doe and 3 by Janet) Query.search('name', "Jane Doe" => Matches 1,2 (doesn't match 3 because there are two words in the query and Jane doesn't match Janet fully)

-N I N J A-
14 Dec, 2023, 15:53

Also searching : "When", still not getting that doc, do it yourself sir

-N I N J A-
14 Dec, 2023, 15:54

No comma included

-N I N J A-
14 Dec, 2023, 15:58

Same to all these keywords: When - total:0 I - total:0 Was - total:0

But searching: "Young" - total:1, got this doc. Why this happening 😭

Ernest
14 Dec, 2023, 16:09

Ok, will test it out

Ernest
14 Dec, 2023, 16:41

Yes, I can confirm this problem. I'm not sure if some words are sanitised. At first I thought it might have been a length of characters issue but it's not. The issue is also not limited to those words. Hopefully a core member can better explain what's going.

Drake
14 Dec, 2023, 17:13

What was the match for "Young"?

-N I N J A-
14 Dec, 2023, 17:18

Yes, for young I am getting the expected doc, eg. {$id..., text: When I was young I used to think that USB is a country next to USAπŸ˜‚}

Drake
14 Dec, 2023, 17:27

When is ignored because it's a stopword I is ignored because it's too short Was is ignored because it's too short

-N I N J A-
14 Dec, 2023, 17:30

Also not getting result, when I am searching: "When I was"

Then how can i ignore stopwords in appwrite?

-N I N J A-
14 Dec, 2023, 17:32

I mean how can allow users to also search stopwords combination?

Ernest
14 Dec, 2023, 17:36

I have an example with 'saw' and that worked so is the length dynamic?

Ernest
14 Dec, 2023, 17:43

I'm confused because searching for 'a' worked (kind of). Btw I'm using the cli to test.

Drake
14 Dec, 2023, 17:43

Actually min length is 3 so that's why saw worked

Ernest
14 Dec, 2023, 17:46

'a' is listed as a stopword but somehow works (again kind of) ...weird

Ernest
14 Dec, 2023, 17:47

Thanks for the link though

Drake
14 Dec, 2023, 17:47

So what gets sent to the DB is a* so whatever words that start with a will be matched. You won't get a result with only a, though. Or even aw because aw is too short

-N I N J A-
14 Dec, 2023, 17:48

So appwrite follows MySQL rules

Ernest
14 Dec, 2023, 17:50

Ok, makes sense. I'd have to test it more to understand fully. I was alread aware query* was being performed but not about the stop words and length

Ernest
14 Dec, 2023, 17:51

Yes, appwrite uses mariaDB which is basically the same as MySQL (from the little I've read)

Ernest
14 Dec, 2023, 17:52

I think you would have to find a way to encode the stop words in such a way that you can still perform a search on them

Ernest
14 Dec, 2023, 17:53

Maybe hashing them in some way

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more