-
-
Notifications
You must be signed in to change notification settings - Fork 179
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[BUG] ft:binary-field does not cast booleans #5193
Comments
It looks like correct conversion for quite a lot of the XDM types is sadly still missing from both the
In principle your suggestion looks good, but it is only 1/2 of the equation. At the moment when the The code for that is in case Type.BOOLEAN:
final BooleanValue bv = new BooleanValue(Boolean.valueOf(content));
return new BinaryDocValuesField(fieldName, new BytesRef(bv.toJavaObject(byte[].class))); Add the following at the top of the private static final byte TRUE_BYTE = 1;
private static final byte FALSE_BYTE = 0;
private static final byte[] TRUE_BYTES = { TRUE_BYTE };
private static final byte[] FALSE_BYTES = { FALSE_BYTE }; and add the following to } else if (target == byte[].class) {
return value ? (T) TRUE_BYTES : (T) FALSE_BYTES;
} but you would also need to implement the function public static AtomicValue deserialize(final ByteBuffer buf) {
return buf.get() == 1 ? TRUE : FALSE;
} Finally you would need to add an additional test-case for binary fields of xs:boolean type to the XQSuite file: https://github.com/eXist-db/exist/blob/eXist-6.2.0/extensions/indexes/lucene/src/test/xquery/lucene/facets.xql Please free free to send a PR for this enhancement. One concern though - Binary Fields in eXist-db appear to have been implemented by using Lucene's
It would seem to me that this would be a bad fit for |
@adamretter thanks for you reply! @line-o self-assigned this issue – so I think he will took a closer look at this issue (let me know, if I can support you in any way). |
Describe the bug
Assuming I have a binary-field definition in my
collection.xconf
like this:and I am using
ft:binary-field
in the following way:It does not cast the retrieved value into a
xs:boolean
.Expected behavior
I would expect – as mentioned in the functions docs and the documentation on the index – that the value is casted or and error is raised. But instead it returns
true
asxs:string
.To Reproduce
See description above.
Context (please always complete the following information)
Notes
I am not a Java person, but after a quick search in the eXist-source I would assume the problem is the missing case in
bytesToAtomic
. I think the addition of the following case might enable correct casting:Otherwise it should be documented what values can be casted by calling
ft:binary-field
.The text was updated successfully, but these errors were encountered: