Enhancing Template Search API - Need Guidance on Vector Search Implementation

Introduction:

I am currently developing a Laravel-based search API that retrieves relevant templates based on user queries. However, I’ve encountered challenges with the current vector search approach.

Requirement Description:

Develop an API that takes a user’s search query as input and returns a template list in response. The goal is to prioritize the most relevant data, ensuring that it appears at the top of the list.

Project Overview:

-Laravel-based API.

-MySQL database with a ‘vectors_table’ table containing tags in the ‘search_category’ column.
-single-store’s vector database to store the search_category(tags) vectors.

What do I want?

I want the template List based on the user search query and all the most relevant data will first be in the list.

For example:

  1. If the user Enters “Independence Day of USA” then the response will first have USA’s Independence Day templates in the List.
  2. If the user Enter “Helloween party” then the response will first have Helloween templates in the List.

Current Approach:

I used the FULL-text search to get the most relevant data first, I successfully got relevant data but the issue triggered when the user entered “American Independence Day”, My USA templates are not listed and I got zero templates in the result.

Proposed Solution:

To resolve this issue and give users more relevant returns based on the search query, I plan to use vector search so that I start using the OpenAI embedding to convert my tags(independence,day,usa) into vectors and store them in single-store’s vector database. Now, if the user enters ‘American Independence Day,’ the USA template is listed, but the issue is that all USA templates are not listed together.

Visualization of Result List:


usa template,

usa template,

usa template,

india template,

usa template,

usa template,

Australia template


In this result, the issue is that the all templates of the USA are not listed together.

Required Result List (All USA templates will be listed together)

usa template,

usa template,

usa template,

usa template,

usa template,

india template,

Australia template


Questions:

  1. How does the vector search process work, and what factors influence the grouping of templates in the result list

  2. How can I ensure that all templates related to a specific country (e.g., USA) are listed together and most relevant(USA) templates will first when users search for variations like “American Independence Day” or “Independence Day of USA”?