Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

fulltext_search

Search text content in Baidu Vector Database tables using BM25 similarity with attribute filtering to retrieve relevant results.

Instructions

Perform full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance. Args: table_name (str): Name of the table to search. index_name (str): Name of the inverted index to perform full text search. search_text (str): Text to search. limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. Returns: str: A string containing the full text search results.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
table_nameYes
index_nameYes
search_textYes
filter_exprNo
limitNo
output_fieldsNo

Implementation Reference

  • The MCP tool handler for 'fulltext_search'. It extracts parameters, calls the underlying connector's fulltext_search method, formats the search results from HttpResponse into a readable string output.
    @mcp.tool() async def fulltext_search( table_name: str, index_name: str, search_text: str, filter_expr: Optional[str] = None, limit: int = 10, output_fields: Optional[list[str]] = None, ctx: Context = None, ) -> str: """ Perform full text search combining BM25 similarity and scalar attribute filtering in the Mochow instance. Args: table_name (str): Name of the table to search. index_name (str): Name of the inverted index to perform full text search. search_text (str): Text to search. limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. Returns: str: A string containing the full text search results. """ connector = ctx.request_context.lifespan_context.connector search_results = await connector.fulltext_search(table_name, index_name, search_text, limit, output_fields, filter_expr) output = f"Full text search results for '{table_name}':\n" for row in search_results.rows: output += f"{str(row["row"])}\n" return output
  • Helper method in the MochowConnector class that implements the core full-text search logic using BM25SearchRequest on the Mochow database client.
    async def fulltext_search( self, table_name: str, index_name: str, search_text: str, limit: int = 10, output_fields: Optional[list[str]] = None, filter_expr: Optional[str] = None, ) -> HttpResponse: """ Perform full text search combining BM25 similarity and scalar attribute filtering. Args: table_name (str): Name of the table to search. index_name (str): Name of the inverted index to perform full text search. search_text (str): Text to search. limit (int): Maximum number of results. Defaults to 10. output_fields (Optional[list[str]]): Fields to return in the results. Defaults to None. filter_expr (Optional[str]): Filter expression for scalar attributes. Defaults to None. Returns: HttpResponse: The HTTP response containing the search results. """ if self.database is None: raise ValueError("Switch to the database before perform full text search.") request = BM25SearchRequest(index_name=index_name, search_text=search_text, limit=limit, filter=filter_expr) try: return self.database.table(table_name).bm25_search(request=request, projections=output_fields) except Exception as e: raise ValueError(f"Failed to perform full text search: {str(e)}")
  • The @mcp.tool() decorator registers the fulltext_search function as an MCP tool.
    @mcp.tool()

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/baidu/mochow-mcp-server-python'

If you have feedback or need assistance with the MCP directory API, please join our Discord server