:wave: I'm using auto detection with a wildcard fi...
# community-help
a
👋 I'm using auto detection with a wildcard field for a certain type of data which can't be known beforehand. It works very well except for one specific use case. I have documents for which 99% of a particular wildcard field will be a string array, but sometimes there is only a single value in the array. It seems like it's not perhaps not possible to have an array field with a single value right now, is that right ?
j
Hi @Aljosa Asanovic, that's correct. If it is a single value, it still has to be inside a single element array.
But I can see how it would be useful to automatically coerce a single value to a single element array. Could you open a Github issue with this request?
a
Hey Jason, ty for the quick answer! I am actually sending it inside a single value array, so normally you're saying that single value arrays would still be automatically detected as arrays and not be auto detected as just string?
j
Oh yes, that's correct
Or at least that's the desired behavior! If it's not working like that, it's a bug 🙂
a
I think the bug is on my side 😄 . Just realized I don't do a pre-check on whether a field may be an array across all documents, so when I get to a document which does not have multiple values, I end up sending it as string.. oops! (and whichever type gets sent first remains the valid type for all documents in the collection) I'll fix and if it still doesn't work, I'll open a bug 🙂
It works perfectly now with my change. Really love your product ❤️
❤️ 1
Reading a bit more now about dealing with "dirty data" and the coerce_or_reject behavior. Does it make sense that it should be possible to coerce a string into a single element array ? The opposite not being possible makes sense, coercing an array into a string is nonsensical
j
Does it make sense that it should be possible to coerce a string into a single element array ?
Yup! This is what I thought you meant originally. We don't do this currently, and I think it makes sense to attempt this coercion
k
We had a recent issue opened on GitHub with the same suggestion. Going to address it.