šŸ” Omnisearch: Integrate Algolia, Typesense, and friends

@ian11 , @drixxon , I just emailed you and all SciousSearch users instructions on making the switch to Omnisearch. Check em out and let me know if you have any questions!

1 Like

thank you so much!

1 Like

I’ve been using Omnisearch for a while now and am generally satisfied with its performance. However, I’m having trouble getting the group_by function to work.
obraz
Implementing it as shown in the image throws the following error: OMNISEARCH ERROR: TypeError: can't access property "map", hits is undefined. When I remove group_by from the advanced options, the error disappears and the results are shown ungrouped. Despite the error, the network logs, as seen below, indicate that the search is being returned correctly, but the plugin isn’t recognizing it.



Here’s the rest of the visual element:
obraz
obraz

Could you help me resolve this issue @zelus_pudding?

Hey Mikolaj,
Thank you again for trusting us with your search - I’m sorry to hear you’ve hit this snag. For starters, I want to make sure you’re on the latest version of Omnisearch. Most people are so next I want you to replace the ["*"] with a spelled list of all of the columns you want to search. I think in your case you can replace that to something like ["Listing"]… we do provide a superset of this list for you if you’re using the sync template (when you go to sync, it’s provided in ā€œstep 2ā€ of the sync flow) which you can copy and paste into this visual element field. That may not fix the issue but let me know how it goes and we’ll go from there.

Hi, thanks for the quick response! Unfortunately, despite updating the plugin and changing the fields to search, the element still throws an error. Notably, removing group_by from the advanced options eliminates the error. This is odd because it was working fine a while back. I made some changes since and had to pivot to a different feature and I do not recall how it was set up previously

Dug up our old support chat and found this. Does this help?

Thank you for your patience Mikolaj, I’ve finally found time to revisit. I see several issues with your setup. First, you do not need to add a * as the search input. Doing so would literally search for the keyword * . Instead, leaving it blank will return all search results. Next, you use ["*'] as the fields to search. This is incorrect and instead you should list the fields you want to search by name (case sensitive). A list of fields is conveniently provided from the sync-search-template after you select the fields you want to sync. You can copy and paste that list into the fields to search input. Thirdly, I believe you defined the advanced options incorrectly. As specified in the docs, this is supposed to be provided as a JSON dictionary (similar to the format of the sort by input. As such, your advanced option should look something more like: {"group_by": "field1,field2"}

Revisiting the instructions provided was the first thing I did after I’ve re-encountered the problem. Regrettably, despite following them the issue persists. It’s worth noting that the error I’ve mentioned disappears after removing the advanced options.

Im getting an error in bubble when attempting to sync - ā€˜failed to fetch’

@zelus_pudding will this work for apps on an agency plan? I’m getting the error failed to fetch whilst trying to sync to typesense.

Confirmed it wont. Is it possible to update the plugin so we’re able to handle the auth? When on agency plan bubble requires username and password to be set for run mode.

@mikolaj,
One last question before I DM you to investigate further, can you confirm that the fields you’d like to group_by are synced to Typesense as facets?

Even if they are, I believe this will still throw an error for you that I’ll need to resolve with a plugin update. With said update, Omnisearch would not be able to return the results in actual groups but we would be able to return the results as a flat list of ungrouped hits in the order they would have been if they were in groups. Is that acceptable for your purposes?

@ Mlewis2016,
I’m looking into the issue you’re running into - I know the source of the problem/failure scenario you’re describing and am looking into an effective workaround.

I do confirm the field is synced as facet:
obraz
I think we will be able to work with ungroupped hits if they are in correct order. This would be a big improvement:)

Thanks, I’ve changed plan now but will be good for the future. Another question, how do we control the style of the highlights?

1 Like

I’m also facing an issue where, when you have highlights turned on, the search no longer searches all the fields listed, it only returns searches for the field which is in the highlighted setting. Removing the field from the highlight setting fixes the issue.

1 Like

Looking to work through these issues today - will be in touch as soon as possible :slight_smile:

2 Likes

Question for ya, @mikolaj - if you say it’s acceptable to have the group_by hits returned not as groups of hits, but a list of hits in the same order as if they had been grouped, then is that output not the same or as good as sorting your search results by the whichever key you wanted to group_by?

Asking, because I’m looking at modifying the plugin to give you this preferred output but it seems to me like it can be accomplished using a sort parameter.

Another question, how do we control the style of the highlights?

@mlewis2016 As you’ve likely noticed, highlights are returned and denoted using BBCode syntax - which is what Bubble uses for formatting rich text inputs. That means that matched/highlighted substrings are enveloped in [b] and [/b] tags. If you want to change the formatting of this, one option is to use regex to replace the occurrence of those tags with your preferred format tags. So if you wanted to highligh text by coloring it red, for example, you could regex replace the [b] and [/b] tags to [color=#fff] and [/color], respectively. If that’s too restrictive for some reason, I could also expose the ability to set the highlight tags (returned from Omnisearch in the first place) in the advanced options.

I’m also facing an issue where, when you have highlights turned on, the search no longer searches all the fields listed, it only returns searches for the field which is in the highlighted setting. Removing the field from the highlight setting fixes the issue.

I think I understand the issue you’re running into. It’s not so much that searches are not being run against all fields, but that highlights are not being returned for all fields in records that matched a search? Did I understand that correctly? If so, what your describing is due to a limitation with Bubble… where we can really only return highlights for one field at a time. Let me know if I understood your situation correctly so I can follow up with some suggestions.

I’m trying to display the capacity of each listing based on the sum of its room capacities and then sort the listings by their total capacity. While you worked on a solution I gave sorting a try, but I couldn’t get it to work properly. I hope it’s possible to make group_by working as initially intended with grouped hits. I’m afraid sorting might not be the workaround here

Out of curiosity - thinking of another approach… are you not able to create a total_room_capacity field on your listing and then sort by that? It’s pretty common to pre-compute values like this to improve search speed (regardless of if it’s Bubble, Algolia or a SQL database powering the search). And in your case it seems like it could simplify things.

Yet another solution is that I’m working on creating an Omnisearch element that can return records straight from Algolia/Typesense (unlike our current element which uses Algolia/Typesense to perform the search and then fetches the matched records from Bubble). This approach comes with the following pros/cons. Let’s start with the cons:

  • Loses the ability to use bubble’s permissions.
  • Requires using Bubble API connector to define the data that gets returned from the new visual element
  • Is a little more work to set up.

Pros:

  • More flexibly use the full results just as Algolia/Typesense natively provides them. So you could get that data ā€œgrouped_byā€ exactly as you’ve seen it in Chrome developer tools.
  • You can still hide records by setting up your search filters correctly / judiciously selecting what fields to return.
  • Does not consume any WU to search.
  • Returns search results faster

Thanks, i’ll try the regex method. For the other point, actually no. If I have field 1, 2 and 3 and have highlights off, it works as expected, if I turn highlights on, it no longer filters based on the search input. Once highlights is turned off, it works again. To summarise, filtering by the same search has different results based on whether highlights is turned on or not.