This message was deleted.
# community-help
s
This message was deleted.
k
You can do [[x,y], [x2,y2]]
e
thanks, giving it a try
trying to create a collection but the errors are a bit weird [just timing out]
Copy code
def create_collection(client, collection_name):
    collection_schema = {
        "name": collection_name,
        "fields": [
            {"name": "data", "type": "object", "facet": True},
            {"name": "content", "type": "object"},
            {"name": "_geoloc", "type": "object[]"},
            {"name": "arbeitsAgentur", "type": "object"},
            {"name": "_geolocTypesense", "type": "geopoint"} #new field containging geo datadata for typesense,
        ],
        "enable_nested_fields": True,
    }

    client.collections.create(collection_schema)
k
You should define the field type as geopoint[]
e
ah ok
k
Also there was a bug with nested geo points fields so you probably need to use a recent 0.25 RC build as well.
e
uhh
I am running this in the cloud
can’t seem to create a collection with this
Copy code
def create_collection(client, collection_name):
    collection_schema = {
        "name": collection_name,
        "fields": [
            {"name": "data", "type": "object", "facet": True},
            {"name": "content", "type": "object"},
            {"name": "_geoloc", "type": "object[]"},
            {"name": "arbeitsAgentur", "type": "object"},
            {
                "name": "_geolocTypesense",
                "type": "geopoint[]",
            },  # new field containging geo datadata for typesense,
        ],
        "enable_nested_fields": True,
    }

    client.collections.create(collection_schema)
k
What error are you getting?
Why is the type of geoloc field object[]
e
that is used for algolia I can remove it, i don’t need it but it’s right now in the documents
k
Check our docs btw, we have examples for geo search
e
ok the collection seems to be created but documenets not being uploaded
k
You'll get an error during import
I mean error message will be returned
You can check that to see what's going wrong
e
yeah that is my next questions
Copy code
Traceback (most recent call last):
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1076, in _send_output
    self.send(chunk)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 998, in send
    self.sock.sendall(data)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1237, in sendall
    v = self.send(byte_view[count:])
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1206, in send
    return self._sslobj.write(data)
TimeoutError: The write operation timed out

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/adapters.py", line 439, in send
    resp = conn.urlopen(
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 726, in urlopen
    retries = retries.increment(
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/util/retry.py", line 403, in increment
    raise six.reraise(type(error), error, _stacktrace)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/packages/six.py", line 734, in reraise
    raise value.with_traceback(tb)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 670, in urlopen
    httplib_response = self._make_request(
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/urllib3/connectionpool.py", line 392, in _make_request
    conn.request(method, url, **httplib_request_kw)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1282, in request
    self._send_request(method, url, body, headers, encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1328, in _send_request
    self.endheaders(body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1277, in endheaders
    self._send_output(message_body, encode_chunked=encode_chunked)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 1076, in _send_output
    self.send(chunk)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/http/client.py", line 998, in send
    self.sock.sendall(data)
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1237, in sendall
    v = self.send(byte_view[count:])
  File "/opt/homebrew/Cellar/python@3.10/3.10.10_1/Frameworks/Python.framework/Versions/3.10/lib/python3.10/ssl.py", line 1206, in send
    return self._sslobj.write(data)
urllib3.exceptions.ProtocolError: ('Connection aborted.', TimeoutError('The write operation timed out'))

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/edondurguti/learning/tkag_jobboard_backend/typesense_upload.py", line 137, in <module>
    main()
  File "/Users/edondurguti/learning/tkag_jobboard_backend/typesense_upload.py", line 114, in main
    import_documents(client, "algolia_jobs-en.json", new_collection_name)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/typesense_upload.py", line 57, in import_documents
    client.collections[collection_name].documents.import_(jsonl_data.encode("utf-8"))
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/typesense/documents.py", line 91, in import_
    api_response = self.api_call.post(self._endpoint_path('import'), documents, params, as_json=False)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/typesense/api_call.py", line 144, in post
    return self.make_request(requests.post, endpoint, as_json,
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/typesense/api_call.py", line 130, in make_request
    raise last_exception
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/typesense/api_call.py", line 101, in make_request
    r = fn(url, headers={ApiCall.API_KEY_HEADER_NAME: self.config.api_key}, **kwargs)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/api.py", line 119, in post
    return request('post', url, data=data, json=json, **kwargs)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/api.py", line 61, in request
    return session.request(method=method, url=url, **kwargs)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/sessions.py", line 530, in request
    resp = self.send(prep, **send_kwargs)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/sessions.py", line 643, in send
    r = adapter.send(request, **kwargs)
  File "/Users/edondurguti/learning/tkag_jobboard_backend/.venv/lib/python3.10/site-packages/requests/adapters.py", line 498, in send
    raise ConnectionError(err, request=request)
requests.exceptions.ConnectionError: ('Connection aborted.', TimeoutError('The write operation timed out'))
k
You might have too small a connection timeout for the import endpoint
If you are sending a lot of docs
e
1800
k
Start with examples here first and then adapt to your use case: https://typesense.org/docs/0.24.1/api/geosearch.html#searching-within-a-radius
e
I think i am struggling to upload the docs with the geotype
k
Try with a single document first with the single document insert endpoint
e
this looks good though right?
Copy code
"_geolocTypesense": [
            [
                51.2978963,
                7.3640853
            ],
            [
                49.622503,
                6.7816074
            ]
        ]
before this I had no problem uploading them
k
If that also doesn't work please post that document, schema and the code and I can try in a bit when I'm back at my desk.
e
works fine if i don’t add the new`_geolocTypesense` field