blob: cdd4f6f8e8a95e2e25cc9276f85c9dbe36182c7a (
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
|
// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.config.model.deploy;
import com.yahoo.searchdefinition.SearchBuilder;
import com.yahoo.vespa.documentmodel.DocumentModel;
import com.yahoo.vespa.model.search.SearchDefinition;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
/**
* Internal helper class to retrieve document model and search definitions.
*
* @author Ulf Lilleengen
* @since 5.1
*/
public class SearchDocumentModel {
private final DocumentModel documentModel;
private final List<SearchDefinition> searchDefinitions;
public SearchDocumentModel(DocumentModel documentModel, List<SearchDefinition> searchDefinitions) {
this.documentModel = documentModel;
this.searchDefinitions = searchDefinitions;
}
public DocumentModel getDocumentModel() {
return documentModel;
}
public List<SearchDefinition> getSearchDefinitions() {
return searchDefinitions;
}
public static SearchDocumentModel fromBuilderAndNames(SearchBuilder builder, Map<String, String> names) {
List<SearchDefinition> ret = new ArrayList<>();
for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) {
ret.add(new SearchDefinition(names.get(search.getName()), search));
}
return new SearchDocumentModel(builder.getModel(), ret);
}
public static SearchDocumentModel fromBuilder(SearchBuilder builder) {
List<SearchDefinition> ret = new ArrayList<>();
for (com.yahoo.searchdefinition.Search search : builder.getSearchList()) {
ret.add(new SearchDefinition(search.getName(), search));
}
return new SearchDocumentModel(builder.getModel(), ret);
}
}
|