Thank you @fabrice and @aojjazz
I tried different strategies (and I found at least one that works) but in the end you are right… it’s not a good idea to rely on the note-prefix to find info in the note field, especially if it’s encoded as msgpack.
The only alternative I see is to filter the transactions in the application, where I can decode the note field and extract the info I need.
It’s less efficient but I can’t see any other viable options.
In case someone is curious, I post below the code for the note-prefix query with msgpack… It’s a bit clumsy but works. However, as @fabrice already said, it is only useful in very limited cases.
byte[] msgpk = Encoder.encodeToMsgPack(<object-to-encode>);
byte[] m = Arrays.copyOfRange(msgpk 0, <desired-prefix-length>);
indexerClient.lookupAccountTransactions(address).assetId(id).notePrefix(m).execute().body()