blob: 06bdb9f69bb7de6009c3c156f6e9524e66c20116 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
#include "queryenvironment.h"
#include <vespa/searchlib/common/geo_location.h>
#include <vespa/searchlib/common/geo_location_spec.h>
#include <vespa/searchlib/common/geo_location_parser.h>
#include <vespa/log/log.h>
LOG_SETUP(".searchvisitor.queryenvironment");
using search::IAttributeManager;
using search::common::GeoLocationParser;
using search::common::GeoLocationSpec;
using search::fef::Properties;
using vespalib::string;
namespace streaming {
namespace {
std::vector<GeoLocationSpec>
parseLocation(const string & location_str)
{
std::vector<GeoLocationSpec> fefLocations;
if (location_str.empty()) {
return fefLocations;
}
GeoLocationParser locationParser;
if (!locationParser.parseOldFormatWithField(location_str)) {
LOG(warning, "Location parse error (location: '%s'): %s. Location ignored.",
location_str.c_str(), locationParser.getParseError());
return fefLocations;
}
auto loc = locationParser.getGeoLocation();
if (loc.has_point) {
fefLocations.push_back(GeoLocationSpec{locationParser.getFieldName(), loc});
}
return fefLocations;
}
}
QueryEnvironment::QueryEnvironment(const string & location_str,
const IndexEnvironment & indexEnv,
const Properties & properties,
const IAttributeManager * attrMgr) :
_indexEnv(indexEnv),
_properties(properties),
_attrCtx(attrMgr->createContext()),
_queryTerms(),
_locations(parseLocation(location_str))
{
}
QueryEnvironment::~QueryEnvironment() {}
} // namespace streaming
|