status: 400 response: {“message”: “Cannot use type...
# community-help
f
status: 400 response: {“message”: “Cannot use type
auto
for
print_types
. It can be used only for a field name containing `.*`“}
j
This is expected. The idea being that is that if you know a field name already, then you probably already know its type as well.
The goal of
auto
was to help automatically resolve data types for fields with regex in them
Do you have a case where the type of
print_types
is not known upfront?
f
Yep,
In this case its a json payload.
j
Do you need to search inside the json fields, or do you just want to store and retrieve it?
f
but there is cases that i dont know.. because i fetch it from an attribute list and there is no field type
in this case just store..
but there is others i need to search and they are facets
j
If you just need to store and retrieve, you actually need not even mention it in the schema
You only need to list fields that you want to search/facet/filter in the schema
but there is others i need to search and they are facets
Could you give me an example use case for this?
f
A have a table in the bd with the list of attributes that the products can have..
j
So each Typesense document is a product record, and the set of fields are dynamic for each product, based on the product type?
f
yep..
But there is like 100 types 😄
its an old db structure
j
I'd recommend defining a field like this in the schema:
Copy code
{ name: "attribute_.*", type: "auto", optional: true }
then when you add the product document to the collection, prefix all the attribute names with
attribute_
f
humm ok cool.. thanks…
will try 😄
👍 1