diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2022-02-05 13:11:04 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-02-05 13:11:04 +0100 |
commit | 0455780c0a1ddb6fad0f5ac1d5c94a6932450815 (patch) | |
tree | 2b07c8f142b434fca1f28fa85afdaa66c4a432a1 /searchsummary | |
parent | af9e7e997ebb0782a9feafdbaff5a7280b21e6c5 (diff) | |
parent | 724cc3927f470a683f63d45d7be96bbf938e2797 (diff) |
Merge pull request #21079 from vespa-engine/arnej/more-geo-rendering
Arnej/more geo rendering
Diffstat (limited to 'searchsummary')
4 files changed, 26 insertions, 0 deletions
diff --git a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp index cfc492d50ee..8f627ac1b9a 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/geoposdfw.cpp @@ -64,6 +64,7 @@ GeoPositionDFW::insertField(uint32_t docid, GetDocsumsState * dsState, ResType, const auto& attribute = get_attribute(*dsState); if (attribute.hasMultiValue()) { uint32_t entries = attribute.getValueCount(docid); + if (entries == 0 && _useV8geoPositions) return; Cursor &arr = target.insertArray(); if (attribute.hasWeightedSetType()) { Symbol isym = arr.resolve("item"); diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp index d3c0caeec48..02bb5d25ca4 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.cpp @@ -3,6 +3,7 @@ #include "resultconfig.h" #include <vespa/vespalib/util/exceptions.h> #include <vespa/vespalib/stllike/hash_map.hpp> +#include <atomic> #include <vespa/log/log.h> LOG_SETUP(".searchlib.docsummary.resultconfig"); @@ -117,6 +118,13 @@ ResultConfig::CreateEnumMaps() } } +namespace { +std::atomic<bool> global_useV8geoPositions = false; +} + +bool ResultConfig::wantedV8geoPositions() { + return global_useV8geoPositions; +} bool ResultConfig::ReadConfig(const vespa::config::search::SummaryConfig &cfg, const char *configId) @@ -126,6 +134,7 @@ ResultConfig::ReadConfig(const vespa::config::search::SummaryConfig &cfg, const int maxclassID = 0x7fffffff; // avoid negative classids _defaultSummaryId = cfg.defaultsummaryid; _useV8geoPositions = cfg.usev8geopositions; + global_useV8geoPositions = cfg.usev8geopositions; for (uint32_t i = 0; rc && i < cfg.classes.size(); i++) { const auto& cfg_class = cfg.classes[i]; diff --git a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h index 8a8bfabaaec..8c5895a779d 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h +++ b/searchsummary/src/vespa/searchsummary/docsummary/resultconfig.h @@ -173,6 +173,8 @@ public: return false; } + // whether last config seen wanted useV8geoPositions = true + static bool wantedV8geoPositions(); /** * @return the name of the given result field type. diff --git a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp index 31b953362dd..597cfe8eb40 100644 --- a/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp +++ b/searchsummary/src/vespa/searchsummary/docsummary/summaryfieldconverter.cpp @@ -2,12 +2,14 @@ #include "summaryfieldconverter.h" #include "linguisticsannotation.h" +#include "resultconfig.h" #include "searchdatatype.h" #include <vespa/document/annotation/alternatespanlist.h> #include <vespa/document/annotation/annotation.h> #include <vespa/document/annotation/spantree.h> #include <vespa/document/annotation/spantreevisitor.h> #include <vespa/document/datatype/documenttype.h> +#include <vespa/document/datatype/positiondatatype.h> #include <vespa/document/fieldvalue/arrayfieldvalue.h> #include <vespa/document/fieldvalue/boolfieldvalue.h> #include <vespa/document/fieldvalue/bytefieldvalue.h> @@ -472,6 +474,18 @@ private: } void visit(const StructFieldValue &value) override { + if (value.getDataType() == &document::PositionDataType::getInstance() + && ResultConfig::wantedV8geoPositions()) + { + auto xv = value.getValue("x"); + auto yv = value.getValue("y"); + if (xv && yv) { + Cursor &c = _inserter.insertObject(); + c.setDouble("lat", double(yv->getAsInt()) / 1.0e6); + c.setDouble("lng", double(xv->getAsInt()) / 1.0e6); + return; + } + } if (*value.getDataType() == *SearchDataType::URI) { FieldValue::UP uriAllValue = value.getValue("all"); if (uriAllValue && |