blob: ce93c1a5c3fa7423a806773dff930f331c015023 (
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
|
// Copyright Yahoo. 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.document.DocumentType;
import com.yahoo.searchdefinition.RankProfileRegistry;
import com.yahoo.document.Field;
import com.yahoo.searchdefinition.Schema;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.vespa.model.container.search.QueryProfiles;
/**
* Adds field sets for 1) fields defined inside document type 2) fields inside search but outside document
*
* @author Vegard Havdal
*/
public class BuiltInFieldSets extends Processor {
public static final String SEARCH_FIELDSET_NAME = "[search]"; // Public due to oddities in position handling.
public static final String INTERNAL_FIELDSET_NAME = "[internal]"; // This one populated from misc places
public BuiltInFieldSets(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(schema, deployLogger, rankProfileRegistry, queryProfiles);
}
@Override
public void process(boolean validate, boolean documentsOnly) {
addDocumentFieldSet();
addSearchFieldSet();
// "Hook" the field sets on search onto the document types, since we will include them
// on the document configs
schema.getDocument().setFieldSets(schema.fieldSets());
}
private void addSearchFieldSet() {
for (SDField searchField : schema.extraFieldList()) {
schema.fieldSets().addBuiltInFieldSetItem(SEARCH_FIELDSET_NAME, searchField.getName());
}
}
private void addDocumentFieldSet() {
for (Field docField : schema.getDocument().fieldSet()) {
if (docField instanceof SDField && ((SDField) docField).isExtraField()) {
continue; // skip
}
schema.fieldSets().addBuiltInFieldSetItem(DocumentType.DOCUMENT, docField.getName());
}
}
}
|