blob: f1e1899391dc15af3c63b7f4a6916aea14fdf739 (
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
|
// Copyright 2016 Yahoo Inc. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root.
package com.yahoo.searchdefinition.processing.multifieldresolver;
import com.yahoo.config.application.api.DeployLogger;
import com.yahoo.language.Linguistics;
import com.yahoo.searchdefinition.Index;
import com.yahoo.searchdefinition.Search;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.document.Stemming;
import com.yahoo.searchdefinition.processing.BuiltInFieldSets;
import com.yahoo.vespa.indexinglanguage.expressions.*;
import com.yahoo.vespa.indexinglanguage.linguistics.AnnotatorConfig;
import java.util.List;
import java.util.logging.Level;
/**
* Class resolving conflicts when fields with different stemming-settings are
* combined into the same index
*/
public class StemmingResolver extends MultiFieldResolver {
public StemmingResolver(String indexName, List<SDField> fields, Search search, DeployLogger logger) {
super(indexName, fields, search, logger);
}
@Override
public void resolve() {
checkStemmingForIndexFields(indexName, fields);
}
private void checkStemmingForIndexFields(String indexName, List<SDField> fields) {
Stemming stemming = null;
SDField stemmingField = null;
for (SDField field : fields) {
if (stemming == null && stemmingField==null) {
stemming = field.getStemming(search);
stemmingField = field;
} else if (stemming != field.getStemming(search)) {
deployLogger.log(Level.WARNING, "Field '" + field.getName() + "' has " + field.getStemming(search) +
", whereas field '" + stemmingField.getName() + "' has " + stemming +
". All fields indexing to the index '" + indexName + "' must have the same stemming." +
" This should be corrected as it will make indexing fail in a few cases.");
}
}
}
}
|