aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib/src/tests/features/prod_features.h
blob: dd15981af1fe127b863a05fd6a551fbf8611881f (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
// Copyright 2016 Yahoo Inc. 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:
    int Main();
    void testFramework();
    void testFtLib();
    void testAge();
    void testAttribute();
    void testAttributeMatch();
    void testCloseness();
    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 testRankingExpression();
    void testTerm();
    void testTermDistance();
    void testUtils();

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);
    void setupForAgeTest(FtFeatureTest & ft, uint64_t docTime);
    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);
    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);
    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 setupForDocumentTest(FtFeatureTest &ft, const vespalib::string & attrName, const vespalib::string & docType);
    void assertDotProduct(feature_t exp, const vespalib::string & vector, uint32_t docId = 1,
                          const vespalib::string & attribute = "wsstr", const vespalib::string & attributeOverride="");
    void setupForDotProductTest(FtFeatureTest & ft);
    void assertFieldMatch(const vespalib::string & spec, const vespalib::string & query, const vespalib::string & field,
                          const search::features::fieldmatch::Params * params = NULL, 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;
};