Skip to main content
Glama
baidu

Baidu Vector Database MCP Server

Official
by baidu

fulltext_search

Search text data in Baidu Vector Database using BM25 similarity and apply scalar attribute filters to refine results for precise, relevant outcomes in MCP applications.

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
filter_exprNo
index_nameYes
limitNo
output_fieldsNo
search_textYes
table_nameYes

Implementation Reference

  • MCP tool handler for 'fulltext_search'. It invokes the connector's fulltext_search method and formats the results as a string for the MCP response.
    @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
  • Implementation of full-text search in MochowConnector class using BM25SearchRequest to query the Mochow database.
    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()

Other Tools

Related Tools

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