year = components[4]    time = components[3]    timezone_offset_minutes = int(components[5])  # Convert the offset to minutes    timezone_hours = timezone_offset_minutes // 60  # Calculate the hours    timezone_minutes = timezone_offset_minutes % 60  # Calculate the remaining minutes    # Create a formatted string for the timestamptz in PostgreSQL format    timestamp_tz_str = f"{year}-{month}-{day} {time}+{timezone_hours:02}{timezone_minutes:02}"    return timestamp_tz_str# Metadata extraction function to extract metadata from a JSON recorddef extract_metadata(record: dict, metadata: dict) -> dict:    record_name, record_email = split_name(record["author"])    metadata["id"] = create_uuid(record["date"])    metadata["date"] = create_date(record["date"])    metadata["author_name"] = record_name    metadata["author_email"] = record_email    metadata["commit_hash"] = record["commit"]    return metadataNext, you'll need to download the sample dataset and place it in the same directory as this notebook.You can use following command:# Download the file using curl and save it as commit_history.csv# Note: Execute this command in your terminal, in the same directory as the notebookcurl -O https://s3.amazonaws.com/assets.timescale.com/ai/ts_git_log.jsonFinally we can initialize the JSON loader to parse the JSON records. We also remove empty records for simplicity.# Define path to the JSON file relative to this notebook# Change this to the path to your JSON fileFILE_PATH = "../../../../../ts_git_log.json"# Load data from JSON file and extract metadataloader = JSONLoader(    file_path=FILE_PATH,    jq_schema='.commit_history[]',    text_content=False,    metadata_func=extract_metadata)documents = loader.load()# Remove documents with None datesdocuments = [doc for doc in documents if doc.metadata["date"] is not None]print(documents[0])    page_content='{"commit": "44e41c12ab25e36c202f58e068ced262eadc8d16", "author": "Lakshmi Narayanan Sreethar<lakshmi@timescale.com>", "date":
This notebook shows how to use the Postgres vector database Timescale Vector. You'll learn how to use TimescaleVector for (1) semantic search, (2) time-based vector search, (3) self-querying, and (4) how to create indexes to speed up queries.
This notebook shows how to use the Postgres vector database Timescale Vector. You'll learn how to use TimescaleVector for (1) semantic search, (2) time-based vector search, (3) self-querying, and (4) how to create indexes to speed up queries. ->: year = components[4]    time = components[3]    timezone_offset_minutes = int(components[5])  # Convert the offset to minutes    timezone_hours = timezone_offset_minutes // 60  # Calculate the hours    timezone_minutes = timezone_offset_minutes % 60  # Calculate the remaining minutes    # Create a formatted string for the timestamptz in PostgreSQL format    timestamp_tz_str = f"{year}-{month}-{day} {time}+{timezone_hours:02}{timezone_minutes:02}"    return timestamp_tz_str# Metadata extraction function to extract metadata from a JSON recorddef extract_metadata(record: dict, metadata: dict) -> dict:    record_name, record_email = split_name(record["author"])    metadata["id"] = create_uuid(record["date"])    metadata["date"] = create_date(record["date"])    metadata["author_name"] = record_name    metadata["author_email"] = record_email    metadata["commit_hash"] = record["commit"]    return metadataNext, you'll need to download the sample dataset and place it in the same directory as this notebook.You can use following command:# Download the file using curl and save it as commit_history.csv# Note: Execute this command in your terminal, in the same directory as the notebookcurl -O https://s3.amazonaws.com/assets.timescale.com/ai/ts_git_log.jsonFinally we can initialize the JSON loader to parse the JSON records. We also remove empty records for simplicity.# Define path to the JSON file relative to this notebook# Change this to the path to your JSON fileFILE_PATH = "../../../../../ts_git_log.json"# Load data from JSON file and extract metadataloader = JSONLoader(    file_path=FILE_PATH,    jq_schema='.commit_history[]',    text_content=False,    metadata_func=extract_metadata)documents = loader.load()# Remove documents with None datesdocuments = [doc for doc in documents if doc.metadata["date"] is not None]print(documents[0])    page_content='{"commit": "44e41c12ab25e36c202f58e068ced262eadc8d16", "author": "Lakshmi Narayanan Sreethar<lakshmi@timescale.com>", "date":