Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Using querySuggestionsPlugin with Typesense #3

Open
MantraMedia opened this issue Jan 13, 2023 · 6 comments
Open

Using querySuggestionsPlugin with Typesense #3

MantraMedia opened this issue Jan 13, 2023 · 6 comments

Comments

@MantraMedia
Copy link

I am not sure if this is the same problem as typesense/typesense#570 but I can not get the suggestion plugin to work with Typesense.

I think the problem is that it does not have a getSources functionality to override Algolia

The error passing the client directly is:

Cannot read properties of undefined (reading 'addAlgoliaAgent')

I somehow could go further in passing

searchClient: typesense.collections('test_index').documents()

and adding the needed q parameter in getSearchParams:

getSearchParams() {
  return { q: '*' }
},

but this results in an error as the format from Algolia is different

0: {"indexName":"test_index","query":"","params":{"hitsPerPage":5,"highlightPreTag":"__aa-highlight__","highlightPostTag":"__/aa-highlight__","q":"*"}}

Did somebody ever get the querySuggestionsPlugin to work with Typesense?

@jasonbosco
Copy link
Member

jasonbosco commented Jan 16, 2023

@MantraMedia The querySuggestionsPlugin is an Algolia specific plugin that's built to work only with their "Query Suggestions" feature. The name sounds generic, but it's actually a feature where they build the suggestions index for you based on query history in a specific index format inside of Algolia. So this plugin requires a document structure in that format.

Alternatively, you can build a similar query history index in Typesense by capturing what users type into the search bar, send it to your backend, aggregate, deduplicate and send those to a new collection in Typesense. Then you can query that index from autocomplete.js

Another alternative is to just hit your main index and show search results in the autocomplete interface.

Here's more context: https://typesense.org/docs/guide/query-suggestions.html

@polarby
Copy link

polarby commented Jul 10, 2023

Alternatively, you can build a similar query history index in Typesense by capturing what users type into the search bar, send it to your backend, aggregate, deduplicate and send those to a new collection in Typesense. Then you can query that index from autocomplete.js

@jasonbosco Why not natively implement this in the type sense API? Typesense makes it so easy to use search, yet lacks major in-build features. It's exhausting and makes users waste resources if every single typesense user has to implement this process on their end...

@jasonbosco
Copy link
Member

@polarby We recently added built-in analytics in the upcoming version. It’s already available in 0.25.0.rc46 if you want to test it out:

https://gist.github.com/jasonbosco/0c49916fc2e7a54f30d961aac111cf4a

@polarby
Copy link

polarby commented Jul 10, 2023

@jasonbosco wow, that might be a game changer. I am excited!

@johancoens
Copy link

Hello @jasonbosco What client library would you need to use to automatically populate the top queries?
And additional question, does the client library prevent the top queries to be flooded with searchterms that do have search results?

@jasonbosco
Copy link
Member

@johancoens The search terms are collected and aggregated on the Typesense server-side. So this feature is agnostic to the client-library used.

As of 0.25.0, the analytics features does not track the number of results returned, only the count of unique search terms. We plan to add this in the release after the upcoming one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants