blob: fec610ec41e3b802a4bbe4fc08cdf6902da1ccc6 (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.Search;
import com.yahoo.vespa.documentmodel.DocumentSummary;
import com.yahoo.vespa.documentmodel.SummaryField;
import com.yahoo.vespa.documentmodel.SummaryTransform;
import com.yahoo.vespa.model.container.search.QueryProfiles;
/**
* <p>All summary fields which are not attributes
* must currently be present in the default summary class,
* since the default summary class also defines the docsum.dat format.
* This processor adds any missing summaries to the default summary.
* When that is decoupled from the actual summaries returned, this
* processor can be removed. Note: the StreamingSummary also takes advantage of
* the fact that default is the superset.</p>
*
* <p>All other summary logic should work unchanged without this processing step
* except that IndexStructureValidator.validateSummaryFields must be changed to
* consider all summaries, not just the default, i.e change to
* if (search.getSummaryField(expr.getFieldName()) == null)</p>
*
* <p>This must be done after other summary processors.</p>
*
* @author bratseth
*/
public class MakeDefaultSummaryTheSuperSet extends Processor {
public MakeDefaultSummaryTheSuperSet(Search search, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(search, deployLogger, rankProfileRegistry, queryProfiles);
}
@Override
public void process(boolean validate, boolean documentsOnly) {
DocumentSummary defaultSummary=search.getSummary("default");
for (SummaryField summaryField : search.getUniqueNamedSummaryFields().values() ) {
if (defaultSummary.getSummaryField(summaryField.getName()) != null) continue;
if (summaryField.getTransform() == SummaryTransform.ATTRIBUTE) continue;
if (summaryField.getTransform() == SummaryTransform.ATTRIBUTECOMBINER) continue;
if (summaryField.getTransform() == SummaryTransform.MATCHED_ATTRIBUTE_ELEMENTS_FILTER) continue;
defaultSummary.add(summaryField.clone());
}
}
}
|