#community-help

Mobile Autocomplete Issue in Web Development

TLDR Prime is experiencing a problem with the autocomplete feature on mobile view. He reached out to both Kishore Nallan and Jason for assistance. Multiple solutions were suggested such as refraining from triggering requests to Typesense for empty queries, but the issue persists.

Powered by Struct AI

1

Oct 05, 2023 (1 month ago)
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
07:15 AM
Hey, so I have a weird issue, as you can see on the attached screen recording. When I use autocomplete on mobile, and I close the result area, it reappears if the loading on the top left has not finished. If it's finished, as you can see ath the end, it will remain closed, as it should. https://youtu.be/wusWxkbT8fU
03:15
Prime
03:15 PM
Kishore Nallan Could you help me too?
Kishore Nallan
Photo of md5-4e872368b2b2668460205b409e95c2ea
Kishore Nallan
03:20 PM
It's not clear if this is a client issue or a server issue. It would be helpful if you can produce the code and the response returned as I'm not familiar with mobile dev.
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
03:33 PM
Here is the code, you just need to run npm i, and npm run start to see the issue yourself. If I watch the demo of an autocompleteJS when I press cancel the menu dissapears, but here it reappears
06:56
Prime
06:56 PM
Kishore Nallan Also, it is website development, just mobile view
Oct 06, 2023 (1 month ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
12:12 AM
I would recommend posting this on Stackoverflow, because it looks like the results are returned from Typesense successfully (since it's displayed in the UI), but the autcomplete.js library is not updating it's state. So it's unrelated to Typesense...
12:13
Jason
12:13 AM
One suggestion is to use this sample project and work backwards to see where the difference is coming from
Oct 10, 2023 (1 month ago)
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:34 AM
Jason I contacted the people at algolia, and they told me to fck off because I use typesense lol

1

06:34
Prime
06:34 AM
The thing is that this issue is not happening if I use algolia api. So I think is a problem in the adapter or something
06:35
Prime
06:35 AM
Also, the sample project is fully html+js, and I use react for mine. Provided the src above.
Oct 11, 2023 (1 month ago)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:38 PM
Could you upload that to Github and send me a link?
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:09 PM
ABove is the whole project zipped
06:10
Prime
06:10 PM
Jason
Oct 12, 2023 (1 month ago)
05:23
Prime
05:23 AM
I made a gh for you
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:50 PM
Prime It looks like every time you click on the autocomplete bar, it triggers this request to Typesense:

curl '' -H 'X-TYPESENSE-API-KEY: <API_KEY>'

Essentially empty values for q, and facetquery... Along with a group_by. This group_by is what's slowing down this query to almost 3.5s, and the loading icon shows up during this time.

A couple of solutions to try:

1. Do you intend to show _all
results when the search bar is clicked? If so, you want to consider adding use_cache=true as a query parameter.
2. If you don't intend to show all results with no terms entered in the autocomplete, you could check for an empty query in the code and not trigger the request to Typesense if that's the case.
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:13 PM
Jason I removed group by. Same thing
06:14
Prime
06:14 PM
Use cache helps a bit, but there is still the problem that the window reappears if I press cancel before the buffer finishes
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:18 PM
Hmm it seemed to help reduce response times when I tried the query without group by when I posted the message above.

May I know how many CPU cores you have on the server that's running Typesense?
06:18
Jason
06:18 PM
&gt; you could check for an empty query in the code and not trigger the request to Typesense if that's the case.
This might be the solution
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:21 PM
I think it's a 2 core VPS, but I check
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:21 PM
And also which version of Typesense this is?
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:25 PM
4 vCore vps
06:26
Prime
06:26 PM
How can I check the version?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:27 PM
GET /debug will return the version
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:32 PM
0.25.0
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:39 PM
Any reason you're using facet_query instead of regular q and query_by: categories?
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:50 PM
Because I want to display a list of not only the results, but also the categories and other facets.
06:50
Prime
06:50 PM
(categoriesPlugin and authorsPlugin)
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:51 PM
Right, you can still just do a simple facet and send the search query in q and query_by
06:52
Jason
06:52 PM
facet_query is useful only for searching within facets to power for eg the "search ingredients" mini search bar in this example: https://recipe-search.typesense.org/?r%5Bquery%5D=Kale
06:53
Jason
06:53 PM
Meaning, you have a set of results returned, and you want to do a search for just the facet values in that resultset, that's when you'd use facet_query
Prime
Photo of md5-696e44f65b98e5b1e2bbbc3d8d7d403d
Prime
06:57 PM
Oh, I see.

Typesense

Lightning-fast, open source search engine for everyone | Knowledge Base powered by Struct.AI

Indexed 3005 threads (79% resolved)

Join Our Community

Similar Threads

Dealing with Timeout Issues with Typesense in Algolia Plugin

Prime encounters timeout while making a typesense request inside a custom algolia autocomplete plugin. Though recommended solutions were tried, the issue wasn't fully resolved.

15
2mo

Troubleshooting Typesense Data Load Issues on Ecommerce Platform

Dương requested help with Typesense data load issues on non-localhost systems. Kishore Nallan and David helped him isolate the problem. It was finally resolved when Dương identified and corrected a router configuration issue.

1

25
2mo
Solved

Issue Resolution and Upgrade Problems in Typesense Version 0.26rc16

Ankit reported an issue with Typesense, which was addressed by Kishore Nallan and Jason. However, Ankit experienced difficulties while trying to upgrade, with the server status showing as "Not ready or lagging" 503. The resolution remains incomplete.

1

19
2mo

Transitioning from Meilisearch to Typesense - Questions and Suggestions

Al is moving from Meilisearch to Typesense and asked for similar matching information features. They also proposed adding daily backups. Kishore Nallan helped them find a workaround, while noting expected complexities, and agreed to include their suggestions in their backlog.

3

51
33mo

Resolving Issues While Upgrading Typesense Server

Ayush had queries about upgrading their Typesense server and updating collections using auto-embeddings. Kishore Nallan clarified all issues, but later discovered that reindexing of non auto-embedded vector fields only is currently supported during altering.

11
2mo
Solved