in src/lindorm_mcp_server/server.py [0:0]
def lindorm_retrieve_from_index(index_name: str, query: str, content_field: str, vector_field: str,
top_k: int = 5, ctx: Context = None) -> str:
"""
Retrieve from an existing indexes(or knowledgebase) using both full-text search and vector search, and return the aggregated results
:param index_name: the index name, or known as knowledgebase name
:param query: the query that you want to search in knowledgebase
:param content_field: the text field that store the content text. You can get it from the index structure by lindorm_get_index_mappings tool
:param vector_field: the vector field that store the vector index. You can get it from the index structure by lindorm_get_index_mappings tool
:param top_k: the result number that you want to return
:return: the most relevant content stored in the knowledgebase.
"""
lindorm_search_client = ctx.request_context.lifespan_context.lindorm_search_client
contents = lindorm_search_client.rrf_search(index_name, query, top_k, content_field, vector_field)
output = f"The retrieving results for query {query} in knowledgebase {index_name} is\n"
output += "\n".join(f"{i + 1}. {content}" for i, content in enumerate(contents))
return output