Browse Source

Revert "Default `include_in_all` for numeric-like types to false"

This reverts commit 66668920386cf8470c4dfc9b5a1b476268ea913e.
Lee Hinman 9 years ago
parent
commit
3f77eacab1

+ 1 - 4
core/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java

@@ -496,10 +496,7 @@ public class DateFieldMapper extends FieldMapper {
     }
 
     @Override
-    protected void parseCreateField(ParseContext originalContext, List<Field> fields) throws IOException {
-        // Date fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
-
+    protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
         String dateAsString;
         if (context.externalValueSet()) {
             Object dateAsObject = context.externalValue();

+ 1 - 4
core/src/main/java/org/elasticsearch/index/mapper/GeoPointFieldMapper.java

@@ -110,10 +110,7 @@ public class GeoPointFieldMapper extends BaseGeoPointFieldMapper  {
     }
 
     @Override
-    protected void parse(ParseContext originalContext, GeoPoint point, String geoHash) throws IOException {
-        // Geopoint fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
-
+    protected void parse(ParseContext context, GeoPoint point, String geoHash) throws IOException {
         if (ignoreMalformed.value() == false) {
             if (point.lat() > 90.0 || point.lat() < -90.0) {
                 throw new IllegalArgumentException("illegal latitude value [" + point.lat() + "] for " + name());

+ 1 - 4
core/src/main/java/org/elasticsearch/index/mapper/GeoShapeFieldMapper.java

@@ -430,10 +430,7 @@ public class GeoShapeFieldMapper extends FieldMapper {
     }
 
     @Override
-    public Mapper parse(ParseContext originalContext) throws IOException {
-        // Numeric fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
-
+    public Mapper parse(ParseContext context) throws IOException {
         try {
             Shape shape = context.parseExternalValue(Shape.class);
             if (shape == null) {

+ 1 - 4
core/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java

@@ -285,10 +285,7 @@ public class IpFieldMapper extends FieldMapper {
     }
 
     @Override
-    protected void parseCreateField(ParseContext originalContext, List<Field> fields) throws IOException {
-        // IP fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
-
+    protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
         Object addressAsObject;
         if (context.externalValueSet()) {
             addressAsObject = context.externalValue();

+ 1 - 3
core/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java

@@ -895,9 +895,7 @@ public class NumberFieldMapper extends FieldMapper {
     }
 
     @Override
-    protected void parseCreateField(ParseContext originalContext, List<Field> fields) throws IOException {
-        // Numeric fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
+    protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
         final boolean includeInAll = context.includeInAll(this.includeInAll, this);
 
         XContentParser parser = context.parser();

+ 1 - 3
core/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java

@@ -364,9 +364,7 @@ public class ScaledFloatFieldMapper extends FieldMapper {
     }
 
     @Override
-    protected void parseCreateField(ParseContext originalContext, List<Field> fields) throws IOException {
-        // Numeric fields, by default, will not be included in _all
-        final ParseContext context = originalContext.setIncludeInAllDefault(false);
+    protected void parseCreateField(ParseContext context, List<Field> fields) throws IOException {
         final boolean includeInAll = context.includeInAll(this.includeInAll, this);
 
         XContentParser parser = context.parser();

+ 3 - 3
core/src/test/java/org/elasticsearch/index/mapper/DateFieldMapperTests.java

@@ -194,8 +194,7 @@ public class DateFieldMapperTests extends ESSingleNodeTestCase {
 
     public void testIncludeInAll() throws Exception {
         String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", "date")
-                .field("include_in_all", true).endObject().endObject()
+                .startObject("properties").startObject("field").field("type", "date").endObject().endObject()
                 .endObject().endObject().string();
 
         DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@@ -213,7 +212,8 @@ public class DateFieldMapperTests extends ESSingleNodeTestCase {
         assertEquals("2016-03-11", fields[0].stringValue());
 
         mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", "date").endObject().endObject()
+                .startObject("properties").startObject("field").field("type", "date")
+                .field("include_in_all", false).endObject().endObject()
                 .endObject().endObject().string();
 
         mapper = parser.parse("type", new CompressedXContent(mapping));

+ 3 - 3
core/src/test/java/org/elasticsearch/index/mapper/IpFieldMapperTests.java

@@ -199,8 +199,7 @@ public class IpFieldMapperTests extends ESSingleNodeTestCase {
 
     public void testIncludeInAll() throws Exception {
         String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", "ip")
-                .field("include_in_all", true).endObject().endObject()
+                .startObject("properties").startObject("field").field("type", "ip").endObject().endObject()
                 .endObject().endObject().string();
 
         DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@@ -218,7 +217,8 @@ public class IpFieldMapperTests extends ESSingleNodeTestCase {
         assertEquals("::1", fields[0].stringValue());
 
         mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", "ip").endObject().endObject()
+                .startObject("properties").startObject("field").field("type", "ip")
+                .field("include_in_all", false).endObject().endObject()
                 .endObject().endObject().string();
 
         mapper = parser.parse("type", new CompressedXContent(mapping));

+ 3 - 3
core/src/test/java/org/elasticsearch/index/mapper/NumberFieldMapperTests.java

@@ -280,8 +280,7 @@ public class NumberFieldMapperTests extends ESSingleNodeTestCase {
 
     public void doTestIncludeInAll(String type) throws Exception {
         String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", type)
-                .field("include_in_all", true).endObject().endObject()
+                .startObject("properties").startObject("field").field("type", type).endObject().endObject()
                 .endObject().endObject().string();
 
         DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@@ -299,7 +298,8 @@ public class NumberFieldMapperTests extends ESSingleNodeTestCase {
         assertEquals("123", fields[0].stringValue());
 
         mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
-                .startObject("properties").startObject("field").field("type", type).endObject().endObject()
+                .startObject("properties").startObject("field").field("type", type)
+                .field("include_in_all", false).endObject().endObject()
                 .endObject().endObject().string();
 
         mapper = parser.parse("type", new CompressedXContent(mapping));

+ 3 - 3
core/src/test/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapperTests.java

@@ -265,8 +265,7 @@ public class ScaledFloatFieldMapperTests extends ESSingleNodeTestCase {
     public void testIncludeInAll() throws Exception {
         String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("field").field("type", "scaled_float")
-                .field("scaling_factor", 10.0)
-                .field("include_in_all", true).endObject().endObject()
+                .field("scaling_factor", 10.0).endObject().endObject()
                 .endObject().endObject().string();
 
         DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@@ -285,7 +284,8 @@ public class ScaledFloatFieldMapperTests extends ESSingleNodeTestCase {
 
         mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
                 .startObject("properties").startObject("field")
-                .field("type", "scaled_float").field("scaling_factor", 10.0).endObject().endObject()
+                .field("type", "scaled_float").field("scaling_factor", 10.0)
+                .field("include_in_all", false).endObject().endObject()
                 .endObject().endObject().string();
 
         mapper = parser.parse("type", new CompressedXContent(mapping));

+ 14 - 13
docs/reference/mapping/fields/all-field.asciidoc

@@ -1,14 +1,14 @@
 [[mapping-all-field]]
 === `_all` field
 
-The `_all` field is a special _catch-all_ field which concatenates the values of
-all of the other string fields into one big string, using space as a delimiter,
-which is then <<analysis,analyzed>> and indexed, but not stored. This means that
-it can be searched, but not retrieved.
+The `_all` field is a special _catch-all_ field which concatenates the values
+of all of the other fields into one big string, using space as a delimiter, which is then
+<<analysis,analyzed>> and indexed, but not stored.  This means that it can be
+searched, but not retrieved.
 
-The `_all` field allows you to search for string values in documents without
-knowing which field contains the value. This makes it a useful option when
-getting started with a new dataset. For instance:
+The `_all` field allows you to search for values in documents without knowing
+which field contains the value.  This makes it a useful option when getting
+started with a new dataset. For instance:
 
 [source,js]
 --------------------------------
@@ -16,7 +16,7 @@ PUT my_index/user/1 <1>
 {
   "first_name":    "John",
   "last_name":     "Smith",
-  "place_of_birth": "New York City"
+  "date_of_birth": "1970-10-24"
 }
 
 GET my_index/_search
@@ -29,15 +29,16 @@ GET my_index/_search
 }
 --------------------------------
 // CONSOLE
-<1> The `_all` field will contain the terms: [ `"john"`, `"smith"`, `"new"`, `"york"`, `"city"` ]
+<1> The `_all` field will contain the terms: [ `"john"`, `"smith"`, `"1970"`, `"10"`, `"24"` ]
 
 [NOTE]
-.Only string values are added to _all
+.All values treated as strings
 =============================================================================
 
-If a `date_of_birth` field mapped as a date were used, or an `age` field that
-was an integer were added, they would not be included in the `_all` field, as
-`_all` only contains content from _string_ fields.
+The `date_of_birth` field in the above example is recognised as a `date` field
+and so will index a single term representing `1970-10-24 00:00:00 UTC`. The
+`_all` field, however, treats all values as strings, so the date value is
+indexed as the three string terms: `"1970"`, `"24"`, `"10"`.
 
 It is important to note that the `_all` field combines the original values
 from each field as a string. It does not combine the _terms_ from each field.

+ 0 - 14
docs/reference/migration/migrate_6_0/mapping.asciidoc

@@ -1,14 +0,0 @@
-[[breaking_60_mapping_changes]]
-=== Mapping changes
-
-==== `include_in_all` default changed to false for numeric/date/ip/geo types
-
-The default unset value for numeric types for the `include_in_all` mapping
-option has been changed from true to false.
-
-This includes:
-
-- All regular numeric types such as int, long, float, scaled-float, double
-- IP addresses
-- Dates
-- Geopoints and Geoshapes