blob: e1c64422653a22635f3a3e66c107546bdde7e4d1 (
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 Vespa.ai. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.vespa.model.application.validation;
import com.yahoo.schema.Index;
import com.yahoo.schema.Schema;
import com.yahoo.schema.derived.DerivedConfiguration;
import com.yahoo.schema.document.ImmutableSDField;
import com.yahoo.schema.document.MatchAlgorithm;
import com.yahoo.vespa.model.application.validation.Validation.Context;
import com.yahoo.vespa.model.search.DocumentDatabase;
import com.yahoo.vespa.model.search.IndexedSearchCluster;
import com.yahoo.vespa.model.search.SearchCluster;
import java.util.Map;
/**
* match:prefix for indexed fields not supported
*
* @author vegardh
*/
public class NoPrefixForIndexes implements Validator {
@Override
public void validate(Context context) {
for (SearchCluster cluster : context.model().getSearchClusters()) {
for (DocumentDatabase docDb : cluster.getDocumentDbs()) {
DerivedConfiguration sdConfig = docDb.getDerivedConfiguration();
if ( ! sdConfig.isStreaming() ) {
Schema schema = sdConfig.getSchema();
for (ImmutableSDField field : schema.allConcreteFields()) {
if (field.doesIndexing()) {
//if (!field.getIndexTo().isEmpty() && !field.getIndexTo().contains(field.getName())) continue;
if (field.getMatching().getAlgorithm().equals(MatchAlgorithm.PREFIX)) {
failField(context, schema, field);
}
for (Map.Entry<String, Index> e : field.getIndices().entrySet()) {
if (e.getValue().isPrefix()) {
failField(context, schema, field);
}
}
}
}
}
}
}
}
private void failField(Context context, Schema schema, ImmutableSDField field) {
context.illegal("For " + schema + ", field '" + field.getName() +
"': match/index:prefix is not supported for indexes.");
}
}
|