#community-help

Issue with Typesense Adapter in React Search Box

TLDR Nikunj encountered an error with Typesense adapter, and Jason suggested using 'typesense-js' for building their custom UI.

Powered by Struct AI
Feb 22, 2023 (10 months ago)
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
10:42 AM
Using typesense adapter for creating a search box in react since morning i am getting this error
Uncaught (in promise) TypeError: typesenseInstantsearchAdapter.search is not a function

my code
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
    server: {
        apiKey: typesense.search_api_key, // Be sure to use an API key that only allows search operations
        nodes: [
            {
                host: typesense.host,
                port: typesense.port,
                protocol: 'https',
            },
        ],
        collectionName: typesense.collectionName
    },
    additionalSearchParameters: {
        query_by: 'email',
    },
})
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
02:35 PM
Could you share the code snippet of how you instantiate react-instantsearch?
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
03:04 PM
const resp = await typesenseInstantsearchAdapter.search({q:query})

Jason
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:06 PM
Are you using react-instantsearch?
03:06
Jason
03:06 PM
Or are you building your own search UI components?
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
03:06 PM
no
03:07
Nikunj
03:07 PM
Building my own UI
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
03:07 PM
If you’re building your own UI, you don’t need to use typesense-instantsearch-adapter
03:07
Jason
03:07 PM
You want to use typesense-js instead: https://github.com/typesense/typesense-js
Nikunj
Photo of md5-e86f551204439999ca28639ea0e038b0
Nikunj
03:11 PM
ok checking, thanks Jason

Typesense

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

Indexed 3015 threads (79% resolved)

Join Our Community