Mapping: When _all is disabled, optimize to not gather all entries, closes #722.
This commit is contained in:
parent
24e95ea7e4
commit
4634ca5cb8
|
@ -25,4 +25,9 @@ package org.elasticsearch.index.mapper;
|
|||
public interface AllFieldMapper extends FieldMapper<Void>, InternalMapper {
|
||||
|
||||
public static final String NAME = "_all";
|
||||
|
||||
/**
|
||||
* Is the all field enabled or not.
|
||||
*/
|
||||
public boolean enabled();
|
||||
}
|
|
@ -160,7 +160,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
} else {
|
||||
value = ((Number) externalValue).byteValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Byte.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -169,12 +169,12 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = (byte) context.parser().shortValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -194,7 +194,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (dateAsString == null) {
|
||||
return null;
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), dateAsString, boost);
|
||||
}
|
||||
|
||||
|
|
|
@ -162,7 +162,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
} else {
|
||||
value = ((Number) externalValue).doubleValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Double.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -171,12 +171,12 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = context.parser().doubleValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
} else {
|
||||
value = ((Number) externalValue).floatValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Float.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +170,12 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = context.parser().floatValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
} else {
|
||||
value = ((Number) externalValue).intValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Integer.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +170,12 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = context.parser().intValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
} else {
|
||||
value = ((Number) externalValue).longValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Long.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +170,12 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = context.parser().longValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -199,6 +199,18 @@ public class ParseContext {
|
|||
this.uid = uid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is all included or not. Will always disable it if {@link org.elasticsearch.index.mapper.AllFieldMapper#enabled()}
|
||||
* is <tt>false</tt>. If its enabled, then will return <tt>true</tt> only if the specific flag is <tt>null</tt> or
|
||||
* its actual value (so, if not set, defaults to "true").
|
||||
*/
|
||||
public boolean includeInAll(Boolean specificIncludeInAll) {
|
||||
if (!docMapper.allFieldMapper().enabled()) {
|
||||
return false;
|
||||
}
|
||||
return specificIncludeInAll == null || specificIncludeInAll;
|
||||
}
|
||||
|
||||
public AllEntries allEntries() {
|
||||
return this.allEntries;
|
||||
}
|
||||
|
|
|
@ -161,7 +161,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
} else {
|
||||
value = ((Number) externalValue).shortValue();
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), Short.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -170,12 +170,12 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (includeInAll == null || includeInAll)) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else {
|
||||
value = context.parser().shortValue();
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), context.parser().text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -140,7 +140,7 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements In
|
|||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), value, boost);
|
||||
}
|
||||
if (!indexed() && !stored()) {
|
||||
|
|
|
@ -210,7 +210,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (ipAsString == null) {
|
||||
return null;
|
||||
}
|
||||
if (includeInAll == null || includeInAll) {
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
context.allEntries().addText(names.fullName(), ipAsString, boost);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue