Skip to content

Commit 3a0e349

Browse files
committed
index original value
1 parent a97bbc4 commit 3a0e349

File tree

3 files changed

+6
-10
lines changed

3 files changed

+6
-10
lines changed

x-pack/plugin/mapper-patterned-text/src/main/java/org/elasticsearch/xpack/patternedtext/PatternedTextDocValues.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ String lookupOrdAsString(long l) throws IOException {
6262
var mergedArgs = argsDocValues.lookupOrd(argsDocValues.nextOrd());
6363
PatternedTextValueProcessor.addRemainingArgs(args, mergedArgs.utf8ToString());
6464
}
65-
return PatternedTextValueProcessor.merge(new PatternedTextValueProcessor.Parts(template, args, null));
65+
return PatternedTextValueProcessor.merge(new PatternedTextValueProcessor.Parts(template, args));
6666
}
6767

6868
@Override

x-pack/plugin/mapper-patterned-text/src/main/java/org/elasticsearch/xpack/patternedtext/PatternedTextFieldMapper.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -132,8 +132,8 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
132132
// Parse template and args.
133133
PatternedTextValueProcessor.Parts parts = PatternedTextValueProcessor.split(value);
134134

135-
// Add template and args index.
136-
context.doc().add(new Field(fieldType().name(), parts.indexed(), fieldType));
135+
// Add index on original value
136+
context.doc().add(new Field(fieldType().name(), value, fieldType));
137137

138138
// Add template doc_values
139139
context.doc().add(new SortedSetDocValuesField(fieldType().templateFieldName(), new BytesRef(parts.template())));

x-pack/plugin/mapper-patterned-text/src/main/java/org/elasticsearch/xpack/patternedtext/PatternedTextValueProcessor.java

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,15 @@ public class PatternedTextValueProcessor {
1616
private static final String DELIMITER = "[\\s\\[\\]]";
1717
private static final String SPACE = " ";
1818

19-
record Parts(String template, List<String> args, String indexed) {
19+
record Parts(String template, List<String> args) {
2020
}
2121

2222
static Parts split(String text) {
2323
StringBuilder template = new StringBuilder();
24-
StringBuilder indexed = new StringBuilder();
2524
List<String> args = new ArrayList<>();
2625
String[] tokens = text.split(DELIMITER);
2726
int textIndex = 0;
28-
for (int i = 0; i < tokens.length; i++) {
29-
String token = tokens[i];
27+
for (String token : tokens) {
3028
if (token.isEmpty()) {
3129
if (textIndex < text.length() - 1) {
3230
template.append(text.charAt(textIndex++));
@@ -36,10 +34,8 @@ static Parts split(String text) {
3634
if (isArg(token)) {
3735
args.add(token);
3836
template.append(TEXT_ARG_PLACEHOLDER);
39-
indexed.append(token).append(SPACE);
4037
} else {
4138
template.append(token);
42-
indexed.append(token).append(SPACE);
4339
}
4440
textIndex += token.length();
4541
if (textIndex < text.length()) {
@@ -49,7 +45,7 @@ static Parts split(String text) {
4945
while (textIndex < text.length()) {
5046
template.append(text.charAt(textIndex++));
5147
}
52-
return new Parts(template.toString(), args, indexed.toString().trim());
48+
return new Parts(template.toString(), args);
5349
}
5450

5551
private static boolean isArg(String text) {

0 commit comments

Comments
 (0)