blob: 2a1afd616bcd2838d11c1257927e05babe4e579a (
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.searchdefinition.RankProfileRegistry;
import com.yahoo.searchdefinition.document.Matching;
import com.yahoo.searchdefinition.document.MatchType;
import com.yahoo.searchdefinition.document.SDField;
import com.yahoo.searchdefinition.document.Stemming;
import com.yahoo.searchdefinition.Schema;
import com.yahoo.vespa.model.container.search.QueryProfiles;
/**
* The implementation of word matching - with word matching the field is assumed to contain a single "word" - some
* contiguous sequence of word and number characters - but without changing the data at the indexing side (as with text
* matching) to enforce this. Word matching is thus almost like exact matching on the indexing side (no action taken),
* and like text matching on the query side. This may be suitable for attributes, where people both expect the data to
* be left as in the input document, and trivially written queries to work by default. However, this may easily lead to
* data which cannot be matched at all as the indexing and query side does not agree.
*
* @author bratseth
*/
public class WordMatch extends Processor {
public WordMatch(Schema schema, DeployLogger deployLogger, RankProfileRegistry rankProfileRegistry, QueryProfiles queryProfiles) {
super(schema, deployLogger, rankProfileRegistry, queryProfiles);
}
public void process(boolean validate, boolean documentsOnly) {
for (SDField field : schema.allConcreteFields()) {
processFieldRecursive(field);
}
}
private void processFieldRecursive(SDField field) {
processField(field);
for (SDField structField : field.getStructFields()) {
processField(structField);
}
}
private void processField(SDField field) {
if (!field.getMatching().getType().equals(MatchType.WORD)) {
return;
}
field.setStemming(Stemming.NONE);
field.getNormalizing().inferLowercase();
field.addQueryCommand("word");
}
}
|