Skip to content
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

FCS result count semantics for "-1" #1

Open
Querela opened this issue Sep 6, 2022 · 1 comment
Open

FCS result count semantics for "-1" #1

Querela opened this issue Sep 6, 2022 · 1 comment

Comments

@Querela
Copy link
Contributor

Querela commented Sep 6, 2022

So, while testing, I found that the special semantics of setting the numberOfRecords to -1 as described in the SRUSearchResultSet of fcs-sru-server is not exactly specified in any specification. Client libraries (like fcs-sru-client) ignore this, too! So following the doc string will lead to invalid and unexpected behavior.

→ So either the doc string has to be adjusted and something should be added to the FCS specification as well as updates to fcs-sru-client.

Details

declaration > getTotalRecordCount

/**
* The number of records matched by the query. If the query fails this must
* be 0. If the search engine cannot determine the total number of matched
* by a query, it must return -1.
*
* @return the total number of results or 0 if the query failed or -1 if the
* search engine cannot determine the total number of results
*/
public abstract int getTotalRecordCount();

The number of records matched by the query. If the query fails this must be 0. If the search engine cannot determine the total number of matched by a query, it must return -1.

serialization > numberOfRecords

// numberOfRecords
out.writeStartElement(ns.getResponseNS(), "numberOfRecords");
out.writeCharacters(
Integer.toString(result.getTotalRecordCount()));
out.writeEndElement(); // "numberOfRecords" element

The value is written as is.

handling of numberOfRecords in fcs-sru-client library (working according to specs)

https://github.com/clarin-eric/fcs-sru-client/blob/18f2bab01b342cf9095db8cfedb10e5b4e9d54da/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java#L938-L940

The value is simply parsed from the XML, it defaults to -1 for invalid cases, e.g. if the surrounding element is not there or can't be parsed. This also should not happen since required=true is set, so rather than a default value, an exception will be thrown...

https://github.com/clarin-eric/fcs-sru-client/blob/18f2bab01b342cf9095db8cfedb10e5b4e9d54da/src/main/java/eu/clarin/sru/client/SRUSimpleClient.java#L955

This only checks for numberOfRecords > 0 and processes results normally. For -1 it does error analysis and in (default) strict mode throws an exception ...

Specs

FCS 2.0

SRU 1.2

SRU 2.0

@benhur1999
Copy link

The missing check for -1 is an error in the implementation. It was planned to enable the search engine implemenation to provide more detail and allow the sru server to be more smart about "search failed" vs "no results" case, i.e. in case of 0 it could automatically set resultCountPrecision to unknown in the SRU 2.0 case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants