diff options
author | Arne Juul <arnej@yahoo-inc.com> | 2018-11-01 09:48:56 +0000 |
---|---|---|
committer | gjoranv <gv@oath.com> | 2019-01-21 15:09:25 +0100 |
commit | 953684a791ac6bb080ecd1c16e77fb57c3fcb85a (patch) | |
tree | 41890aa409898a1ff32cdfdabfb25b812964642d /config-model/src/main | |
parent | df35b45ca1fac714c7255772e03ba218efa8ecd8 (diff) |
Revert "remove "header" and "body" keywords"
This reverts commit e24c1df653d6470089f05786d74e729bb8f82990.
Diffstat (limited to 'config-model/src/main')
3 files changed, 93 insertions, 3 deletions
diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BodyOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BodyOperation.java new file mode 100644 index 00000000000..7ea11873a12 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/BodyOperation.java @@ -0,0 +1,14 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition.fieldoperation; + +import com.yahoo.searchdefinition.document.SDField; + +/** + * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + */ +public class BodyOperation implements FieldOperation { + public void apply(SDField field) { + field.setHeader(false); + field.setHeaderOrBodyDefined(true); + } +} diff --git a/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/HeaderOperation.java b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/HeaderOperation.java new file mode 100644 index 00000000000..22d85f89105 --- /dev/null +++ b/config-model/src/main/java/com/yahoo/searchdefinition/fieldoperation/HeaderOperation.java @@ -0,0 +1,14 @@ +// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. +package com.yahoo.searchdefinition.fieldoperation; + +import com.yahoo.searchdefinition.document.SDField; + +/** + * @author <a href="mailto:einarmr@yahoo-inc.com">Einar M R Rosenvinge</a> + */ +public class HeaderOperation implements FieldOperation { + public void apply(SDField field) { + field.setHeader(true); + field.setHeaderOrBodyDefined(true); + } +} diff --git a/config-model/src/main/javacc/SDParser.jj b/config-model/src/main/javacc/SDParser.jj index 966ef46f6ac..19c410b4b98 100644 --- a/config-model/src/main/javacc/SDParser.jj +++ b/config-model/src/main/javacc/SDParser.jj @@ -265,6 +265,8 @@ TOKEN : | < STEMMING: "stemming" > | < NORMALIZING: "normalizing" > | < BOLDING: "bolding" > +| < BODY: "body" > +| < HEADER: "header" > | < NONE: "none" > | < ON: "on" > | < OFF: "off" > @@ -536,13 +538,35 @@ Object documentBody(SDDocumentType document, Search search) : { ( annotation(search, document) | compression(document, null) + | headercfg(document) + | bodycfg(document) | structInside(document, search) | field(document, search) ) { return null; } } /** - * Consumes a compression block. + * Consumes a document head block. + * + * @param document The document type to modify. + */ +void headercfg(SDDocumentType document) : { } +{ + <HEADER> lbrace() [compression(document, "header") (<NL>)*] <RBRACE> +} + +/** + * Consumes a document body block. + * + * @param document The document type to modify. + */ +void bodycfg(SDDocumentType document) : { } +{ + <BODY> lbrace() [compression(document, "body") (<NL>)*] <RBRACE> +} + +/** + * Consumes a compression block. This can be set in both document header and -body block. * * @param document The document type to modify. * @param name The name of the document block to modify. @@ -554,8 +578,12 @@ void compression(SDDocumentType document, String name) : { <COMPRESSION> lbrace() (cfg = compressionItem(cfg) (<NL>)*)* <RBRACE> { - document.getDocumentType().contentStruct().setCompressionConfig(cfg); - document.getDocumentType().getBodyType().setCompressionConfig(cfg); + if (name == null || name.equals("header")) { + document.getDocumentType().contentStruct().setCompressionConfig(cfg); + } + if (name == null || name.equals("body")) { + document.getDocumentType().getBodyType().setCompressionConfig(cfg); + } } } @@ -938,8 +966,10 @@ String fieldBody(SDField field, Search search, SDDocumentType document) : { } { ( alias(field) | attribute(field) | + body(field) | bolding(field) | fieldStemming(field) | + header(field) | id(field, document) | summaryInField(field) | index(search, field) | @@ -1466,6 +1496,36 @@ void bolding(FieldOperationContainer field) : } } +/** + * This rule consumes a body statement of a field element. + * + * @param field The field to modify. + */ +void body(SDField field) : { } +{ + <BODY> + { + deployLogger.log(Level.WARNING, field + ": 'header/body' is deprecated and has no effect."); + field.setHeader(false); + field.setHeaderOrBodyDefined(true); + } +} + +/** + * This rule consumes a header statement of a field element. + * + * @param field The field to modify. + */ +void header(SDField field) : { } +{ + <HEADER> + { + deployLogger.log(Level.WARNING, field + ": 'header/body' is deprecated and has no effect."); + field.setHeader(true); + field.setHeaderOrBodyDefined(true); + } +} + void queryCommand(FieldOperationContainer container) : { String command; @@ -2421,6 +2481,7 @@ String identifier() : { } | <AS> | <ASCENDING> | <ATTRIBUTE> + | <BODY> | <BOLDING> | <COMPRESSION> | <COMPRESSIONLEVEL> @@ -2450,6 +2511,7 @@ String identifier() : { } | <FULL> | <FUNCTION> | <GRAM> + | <HEADER> | <HUGE> | <ID> | <IDENTICAL> |