Hi! I noticed that when using a joined field in co...
# community-help
h
Hi! I noticed that when using a joined field in combination with pinned_hits, the pinned_hits are not getting any of the joined documents. I guess this is by design since the pinned hits are not being filtered by, but is there a way to get around this?
a
Hi Henrik, Could you kindly create a reproducible example using the template as reference? https://gist.github.com/auth/github?return_to=https%3A%2F%2Fgist.github.com%2Fjasonbosco%2F7c3432713216c378472f13e72246f46b Also, which version are you using?
👀 1
h
version 29.0 got two collections,
products
&
product_data
When searching products with a pinned_hit, joining product_data, the pinned hit do not get
product_data
joined
Copy code
### Run Typesense via Docker ########################################
set -x

export TYPESENSE_API_KEY=xyz
export TYPESENSE_HOST=<http://localhost:8108>

docker stop typesense-repro 2>/dev/null
docker rm typesense-repro 2>/dev/null
rm -rf "$(pwd)"/typesense-data-dir-repro
mkdir "$(pwd)"/typesense-data-dir-repro

# Wait for Typesense to be ready
docker run -d -p 8108:8108 --name typesense-repro \
            -v"$(pwd)"/typesense-data-dir-repro:/data \
            typesense/typesense:29.0 \
            --data-dir /data \
            --api-key=$TYPESENSE_API_KEY \
            --enable-cors

# Wait till typesense is ready.
until curl -s -o /dev/null -w "%{http_code}" "$TYPESENSE_HOST/health" -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" | grep -q "200"; do
  sleep 2
done

curl -s "$TYPESENSE_HOST/debug" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" | jq


curl -s "$TYPESENSE_HOST/collections" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '
          {
             "name": "products",
             "fields": [
               {"name": "name", "type": "string" }
             ]
           }' | jq

curl -s "$TYPESENSE_HOST/collections/products/documents/import?action=create" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "124","name": "First Product"}
            {"id": "125","name": "Second Product"}'  | jq


curl -s "$TYPESENSE_HOST/collections" \
       -X POST \
       -H "Content-Type: application/json" \
       -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
       -d '
          {
             "name": "product_data",
             "fields": [
               {"name": "product_id", "type": "string", "reference": "products.id" },
               {"name": "extra_data", "type": "string" }
             ]
           }' | jq

curl -s "$TYPESENSE_HOST/collections/product_data/documents/import?action=create" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -H "Content-Type: text/plain" \
        -X POST \
        -d '{"id": "124","product_id": "124","extra_data": "foo"}
            {"id": "125","product_id": "125","extra_data": "bar"}'  | jq


curl -s "$TYPESENSE_HOST/collections/products/documents/search" \
        -H "X-TYPESENSE-API-KEY: ${TYPESENSE_API_KEY}" \
        -X GET \
        -G \
        --data-urlencode "q=*" \
        --data-urlencode 'filter_by=$product_data(id:*)' \
        --data-urlencode "pinned_hits=124:1" \
        --data-urlencode "filter_curated_hits=true" | jq '.'

docker stop typesense-repro
docker rm typesense-repro

### Documentation ######################################################################################
# Visit the API reference section: <https://typesense.org/docs/28.0/api/collections.html>
# Click on the "Shell" tab under each API resource's docs, to get shell commands for other API endpoints
a
Perfect @Henrik Sjödahl. Seems like a bug and still happening on recent versions, I will be opening an issue for it.
🙌 1
h
Is there somewhere i can follow the progress of the issue?
a
Yup, is in our official repository: https://github.com/typesense/typesense/issues/2587
1