aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/features/prod_features_test.h
blob: 28b564b341e90590040aa82c8feff9af60fc681b (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
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
// Copyright Yahoo. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.

#pragma once

#include <vespa/searchlib/features/distancetopathfeature.h>
#include <vespa/searchlib/features/termdistancefeature.h>
#include <vespa/searchlib/fef/test/ftlib.h>

class Test : public FtTestApp
{
public:
    Test();
    ~Test() override;
    int Main() override;
    void testFramework();
    static void testFtLib();
    void testAge();
    void testAttribute();
    void testAttributeMatch();
    void testCloseness();
    void testMatchCount();
    void testGreatCircleDistance();
    void testDistance();
    void testDistanceToPath();
    void testDotProduct();
    void testFieldLength();
    void testFieldMatch();
    void testFieldTermMatch();
    void testFirstPhase();
    void testForeach();
    void testFreshness();
    void testMatch();
    void testMatches();
    void testNow();
    void testQuery();
    void testQueryTermCount();
    void testRandom();
    void testRandomNormal();
    void testRandomNormalStable();
    void testRankingExpression();
    void testTerm();
    void testTermDistance();
    void testUnique();
    static void testUtils();

    static void setupForDotProductTest(FtFeatureTest & ft);

private:
    void testFieldMatchBluePrint();
    void testFieldMatchExecutor();
    void testFieldMatchExecutorOutOfOrder();
    void testFieldMatchExecutorSegments();
    void testFieldMatchExecutorGaps();
    void testFieldMatchExecutorHead();
    void testFieldMatchExecutorTail();
    void testFieldMatchExecutorLongestSequence();
    void testFieldMatchExecutorMatches();
    void testFieldMatchExecutorCompleteness();
    void testFieldMatchExecutorOrderness();
    void testFieldMatchExecutorRelatedness();
    void testFieldMatchExecutorLongestSequenceRatio();
    void testFieldMatchExecutorEarliness();
    void testFieldMatchExecutorWeight();
    void testFieldMatchExecutorSignificance();
    void testFieldMatchExecutorImportance();
    void testFieldMatchExecutorOccurrence();
    void testFieldMatchExecutorAbsoluteOccurrence();
    void testFieldMatchExecutorWeightedOccurrence();
    void testFieldMatchExecutorWeightedAbsoluteOccurrence();
    void testFieldMatchExecutorSignificantOccurrence();
    void testFieldMatchExecutorUnweightedProximity();
    void testFieldMatchExecutorReverseProximity();
    void testFieldMatchExecutorAbsoluteProximity();
    void testFieldMatchExecutorMultiSegmentProximity();
    void testFieldMatchExecutorSegmentDistance();
    void testFieldMatchExecutorSegmentProximity();
    void testFieldMatchExecutorSegmentStarts();
    void testFieldMatchExecutorMoreThanASegmentLengthOfUnmatchedQuery();
    void testFieldMatchExecutorQueryRepeats();
    void testFieldMatchExecutorZeroCases();
    void testFieldMatchExecutorExceedingIterationLimit();
    void testFieldMatchExecutorRemaining();

    void assertAge(feature_t expAge, const vespalib::string & attr, uint64_t now, uint64_t docTime);
    static void setupForAgeTest(FtFeatureTest & ft, int64_t docTime);
    static void setupForAttributeTest(FtFeatureTest &ft, bool setup_env = true);
    void assertCloseness(feature_t exp, const vespalib::string & attr, double distance, double maxDistance = 0, double halfResponse = 0);
    static void setupForDistanceTest(FtFeatureTest & ft, const vespalib::string & attrName,
                                     const std::vector<std::pair<int32_t, int32_t> > & positions, bool zcurve);
    void assert2DZDistance(feature_t exp, const vespalib::string & positions,
                           int32_t xquery, int32_t yquery, uint32_t xAspect = 0, uint32_t hit_index = 0);
    void assertDistanceToPath(const std::vector<std::pair<int32_t, int32_t> > & pos, const vespalib::string &path,
                              feature_t distance = search::features::DistanceToPathExecutor::DEFAULT_DISTANCE,
                              feature_t traveled = 1, feature_t product = 0);
    void assertDotProduct(feature_t exp, const vespalib::string & vector, uint32_t docId = 1,
                          const vespalib::string & attribute = "wsstr", const vespalib::string & attributeOverride="");

    void assertFieldMatch(const vespalib::string & spec, const vespalib::string & query, const vespalib::string & field,
                          const search::features::fieldmatch::Params * params = nullptr, uint32_t totalTermWeight = 0, feature_t totalSignificance = 0.0f);
    void assertFieldMatch(const vespalib::string & spec, const vespalib::string & query, const vespalib::string & field,
                          uint32_t totalTermWeight);
    void assertFieldMatchTS(const vespalib::string & spec, const vespalib::string & query, const vespalib::string & field,
                            feature_t totalSignificance);
    vespalib::string getExpression(const vespalib::string &parameter) const;
    void assertForeachOperation(feature_t exp, const vespalib::string & cond, const vespalib::string & op);
    void assertFreshness(feature_t expFreshness, const vespalib::string & attr, uint32_t age, uint32_t maxAge = 0, double halfResponse = 0, bool logScale = false);
    bool assertTermDistance(const search::features::TermDistanceCalculator::Result & exp, const vespalib::string & query,
                            const vespalib::string & field, uint32_t docId = 1);
    bool assertMatches(uint32_t output, const vespalib::string & query, const vespalib::string & field,
                       const vespalib::string & feature = "matches(foo)", uint32_t docId = 1);

private:
    search::fef::BlueprintFactory _factory;
};