3

GitHub - getretake/retake: Open-Source Hybrid Search for Postgres

 10 months ago
source link: https://github.com/getretake/retake
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Retake

Open-Source Hybrid Search for Postgres

DocumentationWebsite

Retake is the fastest way to unlock keyword + semantic search for your database.

By connecting directly to Postgres, Retake accelerates the development of AI applications that require searching, matching, or analyzing database documents. Retake also provides simple search SDKs that snap into any Python or Typescript application.

You don't need to worry about managing separate vector stores and text search engines, uploading and embedding documents, or reindexing data. Just write search queries and let Retake handle the rest.

To get started, run our Docker Compose file:

git clone [email protected]:getretake/retake.git
cd retake/docker
docker compose up

By default, this will start the Retake engine at http://localhost:8000 with API key retake-test-key.

Usage

Python

Install the SDK

pip install retakesearch

The core API is just a few functions.

from retakesearch import Client, Index, Database, Table, Search

client = Client(api_key="retake-test-key", url="http://localhost:8000")

database = Database(
    host="***",
    user="***",
    password="***",
    port=5432
    dbname="***"
)

columns = ["column1"]
table = Table(
    name="table_name",
    columns=columns
)

index = client.create_index("my_index")
# Note: The table must have a primary key
index.add_source(database, table)
index.vectorize(columns)

# Keyword (BM25) search
query = Search().query("match", column1="my query")
response = index.search(query)

# Semantic (vector-based) search
query = Search().with_semantic("my_query", columns)
response = index.search(query)

# Neural (keyword + semantic) search
query = Search().with_neural("my_query", columns)
response = index.search(query)

print(response)

Typescript

Install the SDK

npm install retake-search

The core API is just a few functions.

import { Client, Database, Table, Search } from "retake-search";
import { withSemantic, withNeural, matchQuery } from "retake-search/helpers";

const client = new Client("retake-test-key", "http://localhost:8000");

// Replace with your database credentials
const columns = ["column_to_search"];
const database = new Database({
  host: "***",
  user: "***",
  password: "***",
  dbName: "***",
  port: 5432,
});
const table = new Table({
  table: "table_name",
  columns: columns,
});

const index = client.create_index("table_name");

// Note: The table must have a primary key
index.addSource(database, table);
index.vectorize(columns);

// Keyword (BM25) search
const bm25Query = Search().query(matchQuery("column_to_search", "my query"));
index.search(bm25Query);

// Semantic (vector-based) search
const semanticQuery = Search().query(withSemantic("my query", columns));
index.search(semanticQuery);

// Neural (keyword + semantic) search
const neuralQuery = Search().query(withNeural("my query", columns));
index.search(neuralQuery);

Key Features

arrows_counterclockwiseAlways in Sync

Retake leverages logical-replication-based Change-Data-Capture (CDC) to integrate directly with Postgres. As data changes or new data arrives, Retake ensures that the indexed data is kept in sync.

🧠 Intelligent Vector Cache

Whenever data is changed in Postgres, Retake also updates the embedding/vector representation of that data behind the scenes. Vectors are automatically cached for lightning-fast query results with semantic understanding.

rocketLow-Code SDK

Retake provides intuitive search SDKs that drop into any Python or Typescript application (other languages coming soon). The core API is just a few functions.

zapOpen/ElasticSearch DSL Compatible

Retake enables developers to query with the full expressiveness of the OpenSearch DSL (domain-specific language).

globe_with_meridiansDeployable Anywhere

Retake is deployable anywhere, from a laptop to a distributed cloud system.

How Retake Works

A detailed overview of Retake's architecture can be found in our documentation.

Contributing

For more information on how to contribute, please see our Contributing Guide.

License

Retake is licensed under the Apache-2.0 License.


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK