Revert "Merge remote-tracking branch 'dakrone/exclude-numerics-from-all'"

This reverts commit 514585290c, reversing
changes made to 8563c8d897.
This commit is contained in:
Lee Hinman 2016-08-23 09:24:33 -06:00
parent 8234fad9ca
commit 3298a4ed38
13 changed files with 37 additions and 66 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -178,8 +178,7 @@ public class DateFieldMapperTests extends ESSingleNodeTestCase {
public void testIncludeInAll() throws Exception { public void testIncludeInAll() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "date") .startObject("properties").startObject("field").field("type", "date").endObject().endObject()
.field("include_in_all", true).endObject().endObject()
.endObject().endObject().string(); .endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@ -197,7 +196,8 @@ public class DateFieldMapperTests extends ESSingleNodeTestCase {
assertEquals("2016-03-11", fields[0].stringValue()); assertEquals("2016-03-11", fields[0].stringValue());
mapping = XContentFactory.jsonBuilder().startObject().startObject("type") 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(); .endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping)); mapper = parser.parse("type", new CompressedXContent(mapping));

View File

@ -186,8 +186,7 @@ public class IpFieldMapperTests extends ESSingleNodeTestCase {
public void testIncludeInAll() throws Exception { public void testIncludeInAll() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "ip") .startObject("properties").startObject("field").field("type", "ip").endObject().endObject()
.field("include_in_all", true).endObject().endObject()
.endObject().endObject().string(); .endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@ -205,7 +204,8 @@ public class IpFieldMapperTests extends ESSingleNodeTestCase {
assertEquals("::1", fields[0].stringValue()); assertEquals("::1", fields[0].stringValue());
mapping = XContentFactory.jsonBuilder().startObject().startObject("type") 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(); .endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping)); mapper = parser.parse("type", new CompressedXContent(mapping));

View File

@ -264,8 +264,7 @@ public class NumberFieldMapperTests extends ESSingleNodeTestCase {
public void doTestIncludeInAll(String type) throws Exception { public void doTestIncludeInAll(String type) throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", type) .startObject("properties").startObject("field").field("type", type).endObject().endObject()
.field("include_in_all", true).endObject().endObject()
.endObject().endObject().string(); .endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@ -283,7 +282,8 @@ public class NumberFieldMapperTests extends ESSingleNodeTestCase {
assertEquals("123", fields[0].stringValue()); assertEquals("123", fields[0].stringValue());
mapping = XContentFactory.jsonBuilder().startObject().startObject("type") 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(); .endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping)); mapper = parser.parse("type", new CompressedXContent(mapping));

View File

@ -249,8 +249,7 @@ public class ScaledFloatFieldMapperTests extends ESSingleNodeTestCase {
public void testIncludeInAll() throws Exception { public void testIncludeInAll() throws Exception {
String mapping = XContentFactory.jsonBuilder().startObject().startObject("type") String mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field").field("type", "scaled_float") .startObject("properties").startObject("field").field("type", "scaled_float")
.field("scaling_factor", 10.0) .field("scaling_factor", 10.0).endObject().endObject()
.field("include_in_all", true).endObject().endObject()
.endObject().endObject().string(); .endObject().endObject().string();
DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping)); DocumentMapper mapper = parser.parse("type", new CompressedXContent(mapping));
@ -269,7 +268,8 @@ public class ScaledFloatFieldMapperTests extends ESSingleNodeTestCase {
mapping = XContentFactory.jsonBuilder().startObject().startObject("type") mapping = XContentFactory.jsonBuilder().startObject().startObject("type")
.startObject("properties").startObject("field") .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(); .endObject().endObject().string();
mapper = parser.parse("type", new CompressedXContent(mapping)); mapper = parser.parse("type", new CompressedXContent(mapping));

View File

@ -90,10 +90,10 @@ If you get a hit for your indexed document, the plugin should be installed and w
"took": 53, "took": 53,
"hits": { "hits": {
"total": 1, "total": 1,
"max_score": 0.28582606, "max_score": 0.25811607,
"hits": [ "hits": [
{ {
"_score": 0.28582606, "_score": 0.25811607,
"_index": "trying-out-mapper-attachments", "_index": "trying-out-mapper-attachments",
"_type": "person", "_type": "person",
"_id": "1", "_id": "1",

View File

@ -1,14 +1,14 @@
[[mapping-all-field]] [[mapping-all-field]]
=== `_all` field === `_all` field
The `_all` field is a special _catch-all_ field which concatenates the values of The `_all` field is a special _catch-all_ field which concatenates the values
all of the other string fields into one big string, using space as a delimiter, of all of the other fields into one big string, using space as a delimiter, which is then
which is then <<analysis,analyzed>> and indexed, but not stored. This means that <<analysis,analyzed>> and indexed, but not stored. This means that it can be
it can be searched, but not retrieved. searched, but not retrieved.
The `_all` field allows you to search for string values in documents without The `_all` field allows you to search for values in documents without knowing
knowing which field contains the value. This makes it a useful option when which field contains the value. This makes it a useful option when getting
getting started with a new dataset. For instance: started with a new dataset. For instance:
[source,js] [source,js]
-------------------------------- --------------------------------
@ -16,28 +16,29 @@ PUT my_index/user/1 <1>
{ {
"first_name": "John", "first_name": "John",
"last_name": "Smith", "last_name": "Smith",
"place_of_birth": "New York City" "date_of_birth": "1970-10-24"
} }
GET my_index/_search GET my_index/_search
{ {
"query": { "query": {
"match": { "match": {
"_all": "john smith new york" "_all": "john smith 1970"
} }
} }
} }
-------------------------------- --------------------------------
// CONSOLE // 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] [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 The `date_of_birth` field in the above example is recognised as a `date` field
was an integer were added, they would not be included in the `_all` field, as and so will index a single term representing `1970-10-24 00:00:00 UTC`. The
`_all` only contains content from _string_ fields. `_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 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. from each field as a string. It does not combine the _terms_ from each field.
@ -71,7 +72,7 @@ GET _search
{ {
"query": { "query": {
"query_string": { "query_string": {
"query": "john smith new york" "query": "john smith 1970"
} }
} }
} }
@ -83,7 +84,7 @@ requests>> (which is rewritten to a `query_string` query internally):
[source,js] [source,js]
-------------------------------- --------------------------------
GET _search?q=john+smith+new+york GET _search?q=john+smith+1970
-------------------------------- --------------------------------
Other queries, such as the <<query-dsl-match-query,`match`>> and Other queries, such as the <<query-dsl-match-query,`match`>> and

View File

@ -158,18 +158,6 @@ of the 4 bytes used previously. While this will make the index much more
space-efficient, it also means that index time boosts will be less accurately space-efficient, it also means that index time boosts will be less accurately
encoded. encoded.
==== `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
==== `_ttl` and `_timestamp` cannot be created ==== `_ttl` and `_timestamp` cannot be created
You can no longer create indexes with `_ttl` or `_timestamp` enabled. Indexes You can no longer create indexes with `_ttl` or `_timestamp` enabled. Indexes