@Override public void onRecordAddedToResultSet(QueryContext queryContext, OContextualRecordId recordId, Document ret, final ScoreDoc score) { recordId.setContext(new HashMap<String, Object>() { { put("score", score.score); } }); }
@Override public void onRecordAddedToResultSet(OLuceneQueryContext queryContext, OContextualRecordId recordId, Document ret, final ScoreDoc score) { recordId.setContext(new HashMap<String, Object>() {{ HashMap<String, TextFragment[]> frag = queryContext.getFragments(); frag.entrySet().stream().forEach(f -> { TextFragment[] fragments = f.getValue(); StringBuilder hlField = new StringBuilder(); for (int j = 0; j < fragments.length; j++) { if ((fragments[j] != null) && (fragments[j].getScore() > 0)) { hlField.append(fragments[j].toString()); } } put("$" + f.getKey() + "_hl", hlField.toString()); }); put("$score", score.score); }}); }
@Override public void onRecordAddedToResultSet(OLuceneQueryContext queryContext, OContextualRecordId recordId, Document doc, ScoreDoc score) { OSpatialQueryContext spatialContext = (OSpatialQueryContext) queryContext; if (spatialContext.spatialArgs != null) { Point docPoint = (Point) ctx.readShape(doc.get(strategy.getFieldName())); double docDistDEG = ctx.getDistCalc().distance(spatialContext.spatialArgs.getShape().getCenter(), docPoint); final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM); recordId.setContext(new HashMap<String, Object>() { { put("distance", docDistInKM); } }); } }
@Override public void onRecordAddedToResultSet(QueryContext queryContext, OContextualRecordId recordId, Document doc, ScoreDoc score) { SpatialQueryContext spatialContext = (SpatialQueryContext) queryContext; if (spatialContext.spatialArgs != null) { Point docPoint = (Point) ctx.readShape(doc.get(strategy.getFieldName())); double docDistDEG = ctx.getDistCalc().distance(spatialContext.spatialArgs.getShape().getCenter(), docPoint); final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM); recordId.setContext(new HashMap<String, Object>() { { put("distance", docDistInKM); } }); } }
@Override public void onRecordAddedToResultSet(OLuceneQueryContext queryContext, OContextualRecordId recordId, Document doc, ScoreDoc score) { OSpatialQueryContext spatialContext = (OSpatialQueryContext) queryContext; if (spatialContext.spatialArgs != null) { updateLastAccess(); openIfClosed(); Point docPoint = (Point) ctx.readShape(doc.get(strategy.getFieldName())); double docDistDEG = ctx.getDistCalc().distance(spatialContext.spatialArgs.getShape().getCenter(), docPoint); final double docDistInKM = DistanceUtils.degrees2Dist(docDistDEG, DistanceUtils.EARTH_EQUATORIAL_RADIUS_KM); recordId.setContext(new HashMap<String, Object>() { { put("distance", docDistInKM); } }); } }