{"library":"marqo","title":"Marqo","description":"Marqo is an open-source, RAG-ready vector database and tensor search engine built on OpenSearch. It enables multimodal search across text, images, and other data types using embeddings, simplifying the development of advanced search and Retrieval-Augmented Generation (RAG) applications. Currently at version 3.18.0, Marqo maintains an active development cycle with frequent updates and releases.","language":"python","status":"active","last_verified":"Fri Apr 17","install":{"commands":["pip install marqo"],"cli":{"name":"marqo","version":"sh: 1: marqo: not found"}},"imports":["from marqo import Client"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"import marqo\nimport os\n\n# For local Marqo instances (e.g., via Docker), the URL is often http://localhost:8882\n# For cloud instances, set MARQO_URL and optionally MARQO_API_KEY\nmarqo_url = os.environ.get('MARQO_URL', 'http://localhost:8882')\nmarqo_api_key = os.environ.get('MARQO_API_KEY', None)\n\nmq = marqo.Client(url=marqo_url, api_key=marqo_api_key)\n\nindex_name = \"my-first-marqo-index\"\n\n# Create an index (if it doesn't exist)\ntry:\n    mq.get_index(index_name=index_name)\n    print(f\"Index '{index_name}' already exists.\")\nexcept marqo.errors.MarqoApiError as e:\n    if \"index_not_found\" in str(e).lower():\n        print(f\"Creating index '{index_name}'...\")\n        mq.create_index(index_name=index_name)\n    else:\n        raise e\n\n\n# Add documents to the index\ndocs = [\n    {\n        \"_id\": \"doc1\",\n        \"title\": \"The Art of Computer Programming\",\n        \"description\": \"A series of comprehensive monographs by Donald Knuth covering many topics in computer science.\"\n    },\n    {\n        \"_id\": \"doc2\",\n        \"title\": \"Structure and Interpretation of Computer Programs\",\n        \"description\": \"An influential computer science textbook by Abelson and Sussman, known as SICP.\"\n    }\n]\n\nresponse_add = mq.add_documents(index_name=index_name, documents=docs)\nprint(\"Added documents:\", response_add)\n\n# Perform a search\nsearch_query = \"computer science textbooks\"\nresponse_search = mq.search(index_name=index_name, q=search_query)\nprint(f\"\\nSearch results for '{search_query}':\")\nfor hit in response_search['hits']:\n    print(f\"  Title: {hit['title']}, Score: {hit['_score']:.2f}\")\n\n# Clean up (optional): delete the index\n# mq.delete_index(index_name=index_name)","lang":"python","description":"This quickstart demonstrates how to initialize a Marqo client, create an index, add documents, and perform a basic search. It includes environment variable support for connecting to a Marqo instance and handles index creation idempotently.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}