Bjarte Karlsen
11/26/2024, 11:50 AMError: "Field `<http://updated.at|updated.at>` has been declared in the schema, but is not found in the document.",
Document: "{\"contract\":{\"name\":\"egg\",\"symbol\":\"EGG\",\"address\":\"0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29\",\"network\":\"ethereum\"},\"owner\":\"0xcf851420E8838f89FBda2b392504A81d3B7d5514\",\"status\":\"Active\",\"description\":\"Luigi's uncommon egg is bubbling with cosmic energy. It offers the texture of the stars, and if rubbed vigorously, its power might just glitch your reality.\",\"image\":\"<ipfs://bafybeie2c6iza4grgt4oey4ikes3atxjrixvluy3c34jcx5wx3ojjpmvk4/1>\",\"token_uri\":\"<ipfs://bafybeigeka2kygtdometxgsyok6jgfupc3cpqx2oha5sudvmloxsykkihy/1>\",\"id\":\"ethereum-0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29-1\",\"group\":\"egg\",\"nft_id\":\"1\",\"name\":\"egg\",\"attributes\":[{\"trait_type\":\"tier\",\"string_value\":\"Uncommon\"}],\"updated\":{\"transaction\":\"0xec7f2f75948f5870ee69fd09394d7534a873edab9f0746d50288dec5ebc6bc69\",\"at\":\"2024-10-16 12:34:35 +0000 UTC\",\"timestamp\":1729082075,\"height\":20978152}}",
Bjarte Karlsen
11/26/2024, 11:51 AMBjarte Karlsen
11/26/2024, 12:01 PMFanis Tharropoulos
11/26/2024, 12:07 PM<http://updated.at|updated.at>
is expected to be flattened when passed into the document. Basically everything that's not under an object
field, is flattened in this case, as you don't specify that rarities
or updated
are object fields and their nested children are rarities.max
<http://updated.at|updated.at>
etc. Typesense will automatically infer the structure of the updated
object you pass, but will not associate it with the fields you've explicitly defined as <http://updated.at|updated.at>
. What you'd need to do is have a updated
field with a type of object
or object[]
depending on your use-case, and then define all of them under itBjarte Karlsen
11/26/2024, 12:07 PMBjarte Karlsen
11/26/2024, 12:08 PMFanis Tharropoulos
11/26/2024, 12:08 PM{type: object, name: updated}
as an extra field in your schema and then imported the document as:
❯ curl -X POST "<http://localhost:8108/collections/nft2/documents>" \
-H "Content-Type: application/json" \
-H "X-TYPESENSE-API-KEY: xyz" \
-d '{
"contract": {
"name": "egg",
"symbol": "EGG",
"address": "0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29",
"network": "ethereum"
},
"owner": "0xcf851420E8838f89FBda2b392504A81d3B7d5514",
"status": "Active",
"description": "Luigis uncommon egg is bubbling with cosmic energy. It offers the texture of the stars, and if rubbed vigorously, its power might just glitch your reality.",
"image": "<ipfs://bafybeie2c6iza4grgt4oey4ikes3atxjrixvluy3c34jcx5wx3ojjpmvk4/1>",
"token_uri": "<ipfs://bafybeigeka2kygtdometxgsyok6jgfupc3cpqx2oha5sudvmloxsykkihy/1>",
"id": "ethereum-0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29-1",
"group": "egg",
"nft_id": "1",
"name": "egg",
"attributes": [
{
"trait_type": "tier",
"string_value": "Uncommon"
}
],
"updated": {
"transaction": "0xec7f2f75948f5870ee69fd09394d7534a873edab9f0746d50288dec5ebc6bc69",
"at": "2024-10-16 12:34:35 +0000 UTC",
"timestamp": 1729082075,
"height": 20978152
}
}'
{"attributes":[{"string_value":"Uncommon","trait_type":"tier"}],"contract":{"address":"0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29","name":"egg","network":"ethereum","symbol":"EGG"},"description":"Luigis uncommon egg is bubbling with cosmic energy. It offers the texture of the stars, and if rubbed vigorously, its power might just glitch your reality.","group":"egg","id":"ethereum-0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29-1","image":"<ipfs://bafybeie2c6iza4grgt4oey4ikes3atxjrixvluy3c34jcx5wx3ojjpmvk4/1>","name":"egg","nft_id":"1","owner":"0xcf851420E8838f89FBda2b392504A81d3B7d5514","status":"Active","token_uri":"<ipfs://bafybeigeka2kygtdometxgsyok6jgfupc3cpqx2oha5sudvmloxsykkihy/1>","updated":{"at":"2024-10-16 12:34:35 +0000 UTC","height":20978152,"timestamp":1729082075,"transaction":"0xec7f2f75948f5870ee69fd09394d7534a873edab9f0746d50288dec5ebc6bc69"}}%
Bjarte Karlsen
11/26/2024, 12:08 PMBjarte Karlsen
11/26/2024, 12:09 PMBjarte Karlsen
11/26/2024, 12:16 PM{
"name": "royalties",
"type": "object[]",
"optional": true
},
{
"name": "royalties.address",
"type": "string[]",
"facet": true
},
{
"name": "royalties.cut",
"type": "float[]",
"facet": true
},
{
"name": "royalties.description",
"type": "string[]",
"facet": false,
"index": false,
"optional": true
},
Bjarte Karlsen
11/26/2024, 12:16 PMroyalties.address
has been declared in the schema, but is not found in the document.Bjarte Karlsen
11/26/2024, 12:16 PMBjarte Karlsen
11/26/2024, 12:17 PMBjarte Karlsen
11/26/2024, 12:17 PMBjarte Karlsen
11/26/2024, 12:27 PMFanis Tharropoulos
11/26/2024, 12:39 PMroyalties
wasn't present in the document you posted earlier:
{
"contract": {
"name": "egg",
"symbol": "EGG",
"address": "0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29",
"network": "ethereum"
},
"owner": "0xcf851420E8838f89FBda2b392504A81d3B7d5514",
"status": "Active",
"description": "Luigi's uncommon egg is bubbling with cosmic energy. It offers the texture of the stars, and if rubbed vigorously, its power might just glitch your reality.",
"image": "<ipfs://bafybeie2c6iza4grgt4oey4ikes3atxjrixvluy3c34jcx5wx3ojjpmvk4/1>",
"token_uri": "<ipfs://bafybeigeka2kygtdometxgsyok6jgfupc3cpqx2oha5sudvmloxsykkihy/1>",
"id": "ethereum-0x51bb4c8bb4901d6AA061282cd7Ed916eEc715a29-1",
"group": "egg",
"nft_id": "1",
"name": "egg",
"attributes": [
{
"trait_type": "tier",
"string_value": "Uncommon"
}
],
"updated": {
"transaction": "0xec7f2f75948f5870ee69fd09394d7534a873edab9f0746d50288dec5ebc6bc69",
"at": "2024-10-16 12:34:35 +0000 UTC",
"timestamp": 1729082075,
"height": 20978152
}
}
Bjarte Karlsen
11/26/2024, 12:40 PMBjarte Karlsen
11/26/2024, 12:40 PMBjarte Karlsen
11/26/2024, 12:40 PMFanis Tharropoulos
11/26/2024, 12:40 PMBjarte Karlsen
11/26/2024, 12:41 PMFanis Tharropoulos
11/26/2024, 12:42 PMbut what i am trying to model is that if this item has royalties then the address field must be setThat kind of business logic isn't available in Typesense, you'd want to use an external schema validator library for this purpose before sending the data out to Typesense. If you're using Typescript / Javascript, you can check out zod. For python there's pydantic
Bjarte Karlsen
11/26/2024, 12:42 PM