#community-help

Issues with Search UI for Vector Search

TLDR WL is building a search UI for vector search and having issues with syntax, while Jason provides context on the issue.

Powered by Struct AI
Mar 18, 2023 (7 months ago)
WL
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
WL
05:52 AM
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.
const typesenseInstantsearchAdapter = new TypesenseInstantSearchAdapter({
  server: {
    apiKey: 'Search-only api key', // Search-only api key
    nodes: [
      {
        host: '', // For Typesense Cloud use 
        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',
});
Image 1 for 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.
```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',
});```
06:30
WL
06:30 AM
Image 1 for Testing in <http://localhost:3000/>
Mar 19, 2023 (6 months ago)
Mar 20, 2023 (6 months ago)
WL
Photo of md5-e18fd6bf1ed8f3adba05f7061edef1e1
WL
02:39 AM
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?
02:42
WL
02:42 AM
Because when I tried specifying the vector field in collectionSpecificSearchParameters as per the issue thread, eg.

collectionSpecificSearchParameters: {
     docs: {
      vector_query: 'location',
     },
   }

the search box is disabled for some reason.
Image 1 for Because when I tried specifying the vector field in collectionSpecificSearchParameters as per the issue thread, eg.

```collectionSpecificSearchParameters: {
     docs: {
      vector_query: 'location',
     },
   }```
the search box is disabled for some reason.
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:31 PM
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