Repository: typesense/typesense

Issue #1699: Collection metadata not returned by /collections or /collections/<name>
Created: 2024-04-30T13:51:53Z
Description
The documentation for 26.0 indicates that metadata on a collection should be returned by GET /collections, however running the example in the documentation indicates this isn't the case.
Steps to reproduce


$ curl --silent --verbose -X POST -H 'X-Typesense-API-Key: typesense' --data '{       
  "name": "docs",
  "enable_nested_fields": true,
  "fields": [
    {
      "name": "title",
      "type": "string",
      "facet": true
    }
  ],
  "metadata": {
    "batch_job": 325,
    "indexed_from": "2023-04-20T00:00:00.000Z"
  }
}' localhost:8108/collections

*   Trying [::1]:8108...
* Connected to localhost (::1) port 8108
> POST /collections HTTP/1.1
> Host: localhost:8108
> User-Agent: curl/8.4.0
> Accept: */*
> X-Typesense-API-Key: typesense
> Content-Length: 240
> Content-Type: application/x-www-form-urlencoded
> 
< HTTP/1.1 201 Created
< Connection: keep-alive
< access-control-allow-origin: *
< content-type: application/json; charset=utf-8
< transfer-encoding: chunked
< 
* Connection #0 to host localhost left intact
{"created_at":1714484757,"default_sorting_field":"","enable_nested_fields":true,"fields":[{"facet":true,"index":true,"infix":false,"locale":"","name":"title","optional":false,"sort":false,"stem":false,"type":"string"}],"name":"docs","num_documents":0,"symbols_to_index":[],"token_separators":[]}

Formatted response:
{
  "created_at": 1714484757,
  "default_sorting_field": "",
  "enable_nested_fields": true,
  "fields": [
    {
      "facet": true,
      "index": true,
      "infix": false,
      "locale": "",
      "name": "title",
      "optional": false,
      "sort": false,
      "stem": false,
      "type": "string"
    }
  ],
  "name": "docs",
  "num_documents": 0,
  "symbols_to_index": [],
  "token_separators": []
}


$ curl --silent --verbose -H 'X-Typesense-API-Key: typesense' localhost:8108/collections

*   Trying [::1]:8108...
* Connected to localhost (::1) port 8108
> GET /collections HTTP/1.1
> Host: localhost:8108
> User-Agent: curl/8.4.0
> Accept: */*
> X-Typesense-API-Key: typesense
> 
< HTTP/1.1 200 OK
< Connection: keep-alive
< access-control-allow-origin: *
< content-type: application/json; charset=utf-8
< transfer-encoding: chunked
< 
{ [309 bytes data]
* Connection #0 to host localhost left intact
[{"created_at":1714484757,"default_sorting_field":"","enable_nested_fields":true,"fields":[{"facet":true,"index":true,"infix":false,"locale":"","name":"title","optional":false,"sort":false,"stem":false,"type":"string"}],"name":"docs","num_documents":0,"symbols_to_index":[],"token_separators":[]}]

Formatted response:
[
  {
    "created_at": 1714484757,
    "default_sorting_field": "",
    "enable_nested_fields": true,
    "fields": [
      {
        "facet": true,
        "index": true,
        "infix": false,
        "locale": "",
        "name": "title",
        "optional": false,
        "sort": false,
        "stem": false,
        "type": "string"
      }
    ],
    "name": "docs",
    "num_documents": 0,
    "symbols_to_index": [],
    "token_separators": []
  }
]



Expected Behavior
The collection's metadata should be returned in GET /collections (or GET /collections/<name>).
Actual Behavior
The collection's metadata is not returned.
Metadata
Typesense Version: 26.0
OS: Docker on macOS, typesense/typesense:26.0 image

Duplicate issue #1858: metadata is not shown or not being persisted despite what the documentation says
Created: 2024-07-30T03:34:20Z
Description
Following the documentation to create metadata, the metadata is not persisted.
Steps to reproduce
curl "$TYPESENSE_HOST/collections" \
             -X POST \
             -H "Content-Type: application/json" \
             -H "X-TYPESENSE-API-KEY: $TYPESENSE_API_KEY" \
             -d '{
           "name": "companies",
           "fields": [
             {"name": "company_name", "type": "string" },
             {"name": "num_employees", "type": "int32" },
             {"name": "country", "type": "string", "facet": true }
           ],
           "default_sorting_field": "num_employees", 
           "metadata": { "batch_job": 325 }
         }'

Trying to retrieve it:
> curl --header "x-typesense-api-key: $TYPESENSE_API_KEY" "$TYPESENSE_HOST/collections/companies" | jq .metadata
null

Expected Behavior
Metadata is shown as per the documentation.
Actual Behavior
Metadata is not shown. Possibly not persisted.
Metadata
Typesense Version:
From my Dockerfile
FROM typesense/typesense:26.0

OS:
Docker.

Closing comment (2024-07-30T03:41:12Z): Seems to be a duplicate of #1699 , which I didn't find initially.