Comments (5)
make test
from vespa.
current behavior (via jackson's writeNumberField) is to render -inf as a string "-Infinity", which is legal JSON but not a number (as most users would expect).
I suggest rendering a number which is easy for a human to spot as an "invalid marker" (-1.0 or -999999999 for example). 0.0 is a valid (and common) actual relevance number so we should probably not use that.
from vespa.
Seems like using null
is used for both NaN and +/-Infinity when emitting JSON in JavaScript: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/JSON/stringify
I've also seen suggestions of using +/-1e9999 or similar massive exponents that will (most likely) implicitly roll over to infinity by the receiving parser. Pros: it's still a number. Cons: kinda smelly.
from vespa.
extra con for -1e9999: if the parser is try-hard you could end up with expensive handling of NaN/Inf values (BigDecimal and friends)
from vespa.
I think we should keep current behavior for now.
Fixing this specifically for relevance is easy, diff below. But we should probably wait until Vespa 8, or some customer really needs this fix. Since it's jackson that produces current behavior, it's possible/ that JSON consumers already has handling of it (or is willing to add that). If we make the change, we should also make sure to do it when rendering rank features and other structured data where doubles with possible overflows are rendered to JSON.
diff --git a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
index 31f8194..1e4233c 100644
--- a/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
+++ b/container-search/src/main/java/com/yahoo/search/rendering/JsonRenderer.java
@@ -329,7 +329,13 @@ public class JsonRenderer extends AsynchronousSectionedRenderer<Result> {
if (id != null)
generator.writeStringField(ID, id);
- generator.writeNumberField(RELEVANCE, hit.getRelevance().getScore());
+ generator.writeFieldName(RELEVANCE);
+ double rv = hit.getRelevance().getScore();
+ if (Double.isNaN(rv) || Double.isInfinite(rv)) {
+ generator.writeNull();
+ } else {
+ generator.writeNumber(rv);
+ }
if (hit.types().size() > 0) {
generator.writeArrayFieldStart(TYPES);
from vespa.
Related Issues (20)
- Vespa visit not returning deleted documents when selection criteria is added. HOT 3
- [Schema streaming mode] Enhence rank calculation for substring search HOT 5
- Make behaviour between `global` and `second` phase when `ranking.sorting=''` is given consistent HOT 1
- Allow multiple tensor outputs from native Vespa embedders HOT 3
- Pyvespa deployment fails HOT 5
- [Schema streaming mode] bm25 score is always zero HOT 2
- Array length as search criteria HOT 1
- Sorry couldn't find a discussion tab, so asking here. Can vespa be used as a primary database? HOT 3
- Evaluate onnx models with onnxruntime HOT 3
- Export Vespa golang client API as a library HOT 5
- Parse exception for regular expression HOT 2
- Make YQL Query Syntax Parse Exception more meaningful
- Case sensitive search not supported on index fields HOT 2
- special-tokens not applied for document, only query HOT 1
- Add a topk tensor function for mapped tensors
- Indexing language fails on an empty array HOT 2
- Reindexing is getting stalled
- Inconsistent rendering of string versus array of string with regards to unicode escaping HOT 2
- Vespa 9: Consider updating bm25 hyperparameter defaults
- Segmented And behaviour with weakAnd for CJK languages HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from vespa.