From 3f6108ab746b65b5dd1968b3e62a253bedc970cc Mon Sep 17 00:00:00 2001 From: Nik Everett Date: Tue, 25 Aug 2015 16:01:50 -0400 Subject: [PATCH] [Mapping] Move position_offset_gap default change Until a couple of hours ago we expected the position_offset_gap to default to 0 in 2.0 and 100 in 2.1. We decided it was worth backporting that new default to 2.0. So now that its backported we need to teach 2.1 that 2.0 also defaults to 100. Closes #7268 --- .../index/mapper/core/StringFieldMapper.java | 8 ++++---- .../bwcompat/OldIndexBackwardsCompatibilityIT.java | 2 +- docs/reference/migration/migrate_2_0/mapping.asciidoc | 11 +++++++---- docs/reference/migration/migrate_2_1.asciidoc | 10 ---------- 4 files changed, 12 insertions(+), 19 deletions(-) diff --git a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java index 903660388730d..60ef42a43a91a 100644 --- a/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java +++ b/core/src/main/java/org/elasticsearch/index/mapper/core/StringFieldMapper.java @@ -65,20 +65,20 @@ public static class Defaults { // NOTE, when adding defaults here, make sure you add them in the builder public static final String NULL_VALUE = null; /** - * Post 2.1 default for position_offset_gap. Set to 100 so that + * Post 2.0 default for position_offset_gap. Set to 100 so that * phrase queries of reasonably high slop will not match across field * values. */ public static final int POSITION_OFFSET_GAP = 100; - public static final int POSITION_OFFSET_GAP_PRE_2_1 = 0; + public static final int POSITION_OFFSET_GAP_PRE_2_0 = 0; public static final int IGNORE_ABOVE = -1; /** * The default position_offset_gap for a particular version of Elasticsearch. */ public static int positionOffsetGap(Version version) { - if (version.before(Version.V_2_1_0)) { - return POSITION_OFFSET_GAP_PRE_2_1; + if (version.before(Version.V_2_0_0_beta1)) { + return POSITION_OFFSET_GAP_PRE_2_0; } return POSITION_OFFSET_GAP; } diff --git a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java index 1efc9e888a56c..7b64f4574352a 100644 --- a/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java +++ b/core/src/test/java/org/elasticsearch/bwcompat/OldIndexBackwardsCompatibilityIT.java @@ -446,7 +446,7 @@ void assertDeleteByQueryWorked(String indexName, Version version) throws Excepti } void assertPositionOffsetGapDefaults(String indexName, Version version) throws Exception { - if (version.before(Version.V_2_1_0)) { + if (version.before(Version.V_2_0_0_beta1)) { StringFieldMapperPositionOffsetGapTests.assertGapIsZero(client(), indexName, "doc"); } else { StringFieldMapperPositionOffsetGapTests.assertGapIsOneHundred(client(), indexName, "doc"); diff --git a/docs/reference/migration/migrate_2_0/mapping.asciidoc b/docs/reference/migration/migrate_2_0/mapping.asciidoc index a50fc9c6a6221..67cd214109264 100644 --- a/docs/reference/migration/migrate_2_0/mapping.asciidoc +++ b/docs/reference/migration/migrate_2_0/mapping.asciidoc @@ -384,7 +384,10 @@ The `compress` and `compress_threshold` options have been removed from the default. If you would like to increase compression levels, use the new <> setting instead. - - - - +==== position_offset_gap +The default `position_offset_gap` is now 100. Indexes created in Elasticsearch +2.0.0 will default to using 100 and indexes created before that will continue +to use the old default of 0. This was done to prevent phrase queries from +matching across different values of the same term unexpectedly. Specifically, +100 was chosen to cause phrase queries with slops up to 99 to match only within +a single value of a field. diff --git a/docs/reference/migration/migrate_2_1.asciidoc b/docs/reference/migration/migrate_2_1.asciidoc index 659f33e94829f..7542fb3d1dfdb 100644 --- a/docs/reference/migration/migrate_2_1.asciidoc +++ b/docs/reference/migration/migrate_2_1.asciidoc @@ -25,13 +25,3 @@ GET /my_index/_search?scroll=2m Scroll requests sorted by `_doc` have been optimized to more efficiently resume from where the previous request stopped, so this will have the same performance characteristics as the former `scan` search type. - -=== Mapping changes - -==== position_offset_gap -The default `position_offset_gap` is now 100. Indexes created in Elasticsearch -2.1.0 will default to using 100 and indexes created before that will continue -to use the old default of 0. This was done to prevent phrase queries from -matching across different values of the same term unexpectedly. Specifically, -100 was chosen to cause phrase queries with slops up to 99 to match only within -a single value of a field.