Has anyone tried building a search UI for vector s...
# community-help
w
Has anyone tried building a search UI for vector search? I tried customizing from the InstantSearch.js but I can't seem to search by vectors? What I did was to index a document into Typesense. Then I tried to see if I can search using the search bar, and it doesn't seem to work? Wasn't sure about the syntax for
additionalSearchParameters
or
collectionSpecificSearchParameters
eg.
Copy code
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: 'Search-only api key', // Search-only api key
    nodes: [
      {
        host: '<http://xxx.a1.typesense.net|xxx.a1.typesense.net>', // For Typesense Cloud use <http://xxx.a1.typesense.net|xxx.a1.typesense.net>
        port: '443', // For Typesense Cloud use 443
        protocol: 'https', // For Typesense Cloud use https
      },
    ],
  },
  // The following parameters are directly passed to Typesense's search API endpoint.
  //  So you can pass any parameters supported by the search endpoint below.
  //  queryBy is required.
  //  filterBy is managed and overridden by InstantSearch.js. To set it, you want to use one of the filter widgets like refinementList or use the `configure` widget.
  additionalSearchParameters: {
   query_by: 'title'
  },
  collectionSpecificSearchParameters: {
    docs: {
      query_by: 'location',
    },
  },
});
const searchClient = typesenseInstantsearchAdapter.searchClient;

const search = instantsearch({
  searchClient,
  indexName: 'docs',
});
w
Does this means in the current adapter, there's no way to pass the vector field as a param within additionalSearchParameters/collectionSpecificSearchParameters? So I wouldn't be able to search via vectors in the search box and have the search results displayed using the hits widget?
Because when I tried specifying the vector field in collectionSpecificSearchParameters as per the issue thread, eg.
Copy code
collectionSpecificSearchParameters: {
     docs: {
      vector_query: 'location',
     },
   }
the search box is disabled for some reason.
j
You can indeed pass
vector_query
in
collectionSpecificSearchParameters
or
additionalSearchParameters
, but you’d need to pass in the embeddings in the vector_query format, like in this code sample: https://typesense.org/docs/0.24.0/api/vector-search.html#nearest-neighbor-vector-search