-
Notifications
You must be signed in to change notification settings - Fork 165
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
Iterators and range_filter error (when no range filter is specified) #881
Comments
Tried Milvus 2.4.0 as well - still getting the error. |
Just in case someone will experience this very same issue, I managed to solve it by:
This wasy the iterators are working fine. I assume that sdk 2.4.0 iterators have been tested with Milvus 2.4.0 - so I think that it is something on my side, but I wasn't able to track it down (apart going back to Milvus 2.3.3)… |
A valid range search param for L2 metric should be:
|
Thanks for your clarification, but my search does not use L2 - it actually uses |
But you set "radius"=1.0 and "range_filter"=1.0, the two parameters cannot be equal, neither with IP nor L2. With IP metric type, the value of radius should be less than range_filter.
|
I see - thank you for pointing it. However:
|
I thought it is because you don't specify metrics when you create index. and by default it is L2. |
Guys, I finally found the bugs. There are - according to my investigations - two (unrelated) bugs: Bug n.1In statement that starts at this line:
the metric type is NOT initialized using the searchIteratorParam.getMetricType(). This affects ONLY the iterator.next calls subsequent to the first one: the SDK computes correctly the new params, BUT, given that the metric type is not re-initialized AND I am using IP which is NOT the default, the server thinks that the intended metric is L2 (the default), and therefore it complains that the range and radius paramters are inverted - which indeed are NOT, but only if the correct metric type is reported to the server. Bug n. 2This bug is actually unrelated to bug n.1 - it just happened to occur while I was trying hard to find a workaround to bug n. 1 (well, before I understood the very nature of that first issue, of course). In this line:
the result of params.get(RADIUS) is cast to a Float - but this leads to a casting error because params.get(RADIUS) is read as a Double, which of course cannot be just cast to a Float. BTW the parameter is read as a Double because this is parsed via JacksonUtils.fromJson(searchIteratorParam.getParams(), new TypeReference<Map<String, Object>>(){}) , and Jackson wil always read a real number as a Double in this case, and this behaviour is not - to my knowledge - configurable.
So, if you confirm my findings, I will report the Bug. n. 2 in another issue. I would like to highlight that bug n. 1 is blocking for whoever wants to use iterators with IP metric in Java. |
…chIterator#executeNextSearch (milvus-io#881)
…chIterator#executeNextSearch (milvus-io#881)
Thanks for reporting the bugs. |
Hi @xiaofan-luan ,
Actually I already attached a PR fixing bug n. 1 - the fix was trivial, but I am a bit in the rush and wasn't even able to run the unit tests, let alone adding a new one… so I would like to ask if someone could please add the related unit test, thank you.
I will do the fix - ditto for the unit tests.
I am not sure I am getting your point… reason of what, exactly? The cast from Double to Float is forbidden by the VM, if done as it has been done in the code base (the root of all evil is of course in first place having used a Map of Objects… imho choices like this nullify the whole point of having a type system, and in the end lead to "undetectable" bugs like this one) - the way to go is Double.floatValue(), so in this case |
pr looks good to me, please fix the DCO so I can merge the PR, thanks for the contribution. |
I just tried the IteratorExample.java, I got the exception about the cast:
I agree the executeNextSearch() should pass the metricType to SearchParam, it is a bug. |
Thanks for the clarification . I think the reason is not cast double to int, but to convert a object to primitive directly. make sense to me |
You are wrong - look at this code from JShell - no primitives here, and the error message is very clear:
|
@PiercarloSlavazza So, if you want to use MetricType.IP, you can specify it to the index:
And we don't need to change the code of SearchIterator. |
…chIterator#executeNextSearch (milvus-io#881) Signed-off-by: PiercarloSlavazza <[email protected]>
…chIterator#executeNextSearch (milvus-io#881) Signed-off-by: PiercarloSlavazza <[email protected]>
Hi,
|
@PiercarloSlavazza |
…chIterator#executeNextSearch (#881) (#883) Signed-off-by: PiercarloSlavazza <[email protected]> Co-authored-by: Piercarlo Slavazza <[email protected]>
…chIterator#executeNextSearch (milvus-io#881) Signed-off-by: PiercarloSlavazza <[email protected]>
|
The code logic is a bit different between 2.3 and 2.4 and cause the conflict. I have merged the pr to 2.3 branch. |
…chIterator#executeNextSearch (#881) (#888) Signed-off-by: PiercarloSlavazza <[email protected]> Co-authored-by: Piercarlo Slavazza <[email protected]>
I started to use the search iterators.
I am using:
I create the SearchIteratorParam in the following way:
and afterwards I experience the following weird behaviour:
This is very strange because:
Moreover, if I try to set radius/rangefilter so that the defaults do not kick in, such as in
I have only found this potentially related issue: milvus-io/milvus#29305
Any hint?
Thank you.
The text was updated successfully, but these errors were encountered: