File tree Expand file tree Collapse file tree 2 files changed +27
-0
lines changed
main/java/org/elasticsearch/xpack/logsdb/patternedtext
yamlRestTest/resources/rest-api-spec/test/patternedtext Expand file tree Collapse file tree 2 files changed +27
-0
lines changed Original file line number Diff line number Diff line change 1111import org .apache .lucene .document .FieldType ;
1212import org .apache .lucene .document .SortedSetDocValuesField ;
1313import org .apache .lucene .index .IndexOptions ;
14+ import org .apache .lucene .index .IndexableField ;
1415import org .apache .lucene .util .BytesRef ;
1516import org .elasticsearch .common .util .FeatureFlag ;
1617import org .elasticsearch .index .IndexVersion ;
@@ -132,6 +133,11 @@ protected void parseCreateField(DocumentParserContext context) throws IOExceptio
132133 return ;
133134 }
134135
136+ var existingValue = context .doc ().getField (fieldType ().name ());
137+ if (existingValue != null ) {
138+ throw new IllegalArgumentException ("Multiple values are not allowed for field [" + fieldType ().name () + "]." );
139+ }
140+
135141 // Parse template and args.
136142 PatternedTextValueProcessor .Parts parts = PatternedTextValueProcessor .split (value );
137143
Original file line number Diff line number Diff line change @@ -308,5 +308,26 @@ tsdb:
308308 " dimension" : "a"
309309 foo : " Apache Lucene powers Elasticsearch"
310310
311+ ---
312+ Multiple values :
313+ - do :
314+ indices.create :
315+ index : test1
316+ body :
317+ mappings :
318+ properties :
319+ foo :
320+ type : patterned_text
321+ - do :
322+ catch : bad_request
323+ index :
324+ index : test1
325+ id : " 1"
326+ body : {
327+ " foo " : [
328+ " Found 5 errors for service [cheddar1]" ,
329+ " [2020-08-18T00:58:56] Found 123 errors for service [cheddar1]"
330+ ]
331+ }
311332
312333
You can’t perform that action at this time.
0 commit comments