index: no should also disable include_in_all, closes #1087.
This commit is contained in:
parent
0f0b41e4fa
commit
ec6fa83856
|
@ -21,6 +21,7 @@ package org.elasticsearch.index.mapper;
|
|||
|
||||
import org.apache.lucene.analysis.Analyzer;
|
||||
import org.apache.lucene.document.Document;
|
||||
import org.apache.lucene.document.Field;
|
||||
import org.elasticsearch.common.lucene.all.AllEntries;
|
||||
import org.elasticsearch.common.util.concurrent.NotThreadSafe;
|
||||
import org.elasticsearch.common.xcontent.XContentParser;
|
||||
|
@ -216,16 +217,24 @@ public class ParseContext {
|
|||
this.uid = uid;
|
||||
}
|
||||
|
||||
public boolean includeInAll(Boolean includeInAll, FieldMapper mapper) {
|
||||
return includeInAll(includeInAll, mapper.index());
|
||||
}
|
||||
|
||||
/**
|
||||
* Is all included or not. Will always disable it if {@link org.elasticsearch.index.mapper.internal.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").
|
||||
* its actual value (so, if not set, defaults to "true") and the field is indexed.
|
||||
*/
|
||||
public boolean includeInAll(Boolean specificIncludeInAll) {
|
||||
private boolean includeInAll(Boolean specificIncludeInAll, Field.Index index) {
|
||||
if (!docMapper.allFieldMapper().enabled()) {
|
||||
return false;
|
||||
}
|
||||
return specificIncludeInAll == null || specificIncludeInAll;
|
||||
// not explicitly set
|
||||
if (specificIncludeInAll == null) {
|
||||
return index != Field.Index.NO;
|
||||
}
|
||||
return specificIncludeInAll;
|
||||
}
|
||||
|
||||
public AllEntries allEntries() {
|
||||
|
|
|
@ -192,7 +192,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
} else {
|
||||
value = ((Number) externalValue).byteValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Byte.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -229,7 +229,7 @@ public class ByteFieldMapper extends NumberFieldMapper<Byte> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = (byte) parser.shortValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -273,7 +273,7 @@ public class DateFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (dateAsString == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), dateAsString, boost);
|
||||
}
|
||||
|
||||
|
|
|
@ -188,7 +188,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
} else {
|
||||
value = ((Number) externalValue).doubleValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Double.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -198,7 +198,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -225,7 +225,7 @@ public class DoubleFieldMapper extends NumberFieldMapper<Double> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = parser.doubleValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -187,7 +187,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
} else {
|
||||
value = ((Number) externalValue).floatValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Float.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -197,7 +197,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -224,7 +224,7 @@ public class FloatFieldMapper extends NumberFieldMapper<Float> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = parser.floatValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
} else {
|
||||
value = ((Number) externalValue).intValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Integer.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -229,7 +229,7 @@ public class IntegerFieldMapper extends NumberFieldMapper<Integer> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = parser.intValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
} else {
|
||||
value = ((Number) externalValue).longValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Long.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -229,7 +229,7 @@ public class LongFieldMapper extends NumberFieldMapper<Long> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = parser.longValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -192,7 +192,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
} else {
|
||||
value = ((Number) externalValue).shortValue();
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), Short.toString(value), boost);
|
||||
}
|
||||
} else {
|
||||
|
@ -202,7 +202,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
return null;
|
||||
}
|
||||
value = nullValue;
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll))) {
|
||||
if (nullValueAsString != null && (context.includeInAll(includeInAll, this))) {
|
||||
context.allEntries().addText(names.fullName(), nullValueAsString, boost);
|
||||
}
|
||||
} else if (parser.currentToken() == XContentParser.Token.START_OBJECT) {
|
||||
|
@ -229,7 +229,7 @@ public class ShortFieldMapper extends NumberFieldMapper<Short> {
|
|||
value = objValue;
|
||||
} else {
|
||||
value = parser.shortValue();
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), parser.text(), boost);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,7 @@ public class StringFieldMapper extends AbstractFieldMapper<String> implements Al
|
|||
if (value == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), value, boost);
|
||||
}
|
||||
if (!indexed() && !stored()) {
|
||||
|
|
|
@ -180,13 +180,13 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
long iValue = ipToLong(value);
|
||||
long iSim;
|
||||
try {
|
||||
iSim = ipToLong(minSim);
|
||||
iSim = ipToLong(minSim);
|
||||
} catch (ElasticSearchIllegalArgumentException e) {
|
||||
try {
|
||||
iSim = Long.parseLong(minSim);
|
||||
} catch (NumberFormatException e1) {
|
||||
iSim = (long) Double.parseDouble(minSim);
|
||||
}
|
||||
try {
|
||||
iSim = Long.parseLong(minSim);
|
||||
} catch (NumberFormatException e1) {
|
||||
iSim = (long) Double.parseDouble(minSim);
|
||||
}
|
||||
}
|
||||
return NumericRangeQuery.newLongRange(names.indexName(), precisionStep,
|
||||
iValue - iSim,
|
||||
|
@ -237,7 +237,7 @@ public class IpFieldMapper extends NumberFieldMapper<Long> {
|
|||
if (ipAsString == null) {
|
||||
return null;
|
||||
}
|
||||
if (context.includeInAll(includeInAll)) {
|
||||
if (context.includeInAll(includeInAll, this)) {
|
||||
context.allEntries().addText(names.fullName(), ipAsString, boost);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue