aboutsummaryrefslogtreecommitdiffstats
path: root/searchcore/src/vespa/searchcore/proton/matching/sameelementmodifier.cpp
blob: b4c7cf51bf2337fc4642eb4079336f4c7f719053 (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
// Copyright Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#include "sameelementmodifier.h"
#include <vespa/vespalib/util/classname.h>
#include <vespa/log/log.h>
LOG_SETUP(".matching.sameelementmodifier");

namespace proton::matching {

void
SameElementModifier::visit(ProtonNodeTypes::SameElement &n) {
    if (n.getView().empty()) return;

    vespalib::string prefix = n.getView() + ".";
    for (search::query::Node * child : n.getChildren()) {
        search::query::TermNode * term  = dynamic_cast<search::query::TermNode *>(child);
        if (term != nullptr) {
            term->setView(prefix + term->getView());
        } else {
            LOG(error, "Required a search::query::TermNode. Got %s", vespalib::getClassName(*child).c_str());
        }
    }
}

}