Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@

import java.time.ZoneId;
import java.util.Collections;
import java.util.Objects;
import java.util.function.Supplier;

public class TypeFieldMapper extends MetadataFieldMapper {
Expand Down Expand Up @@ -137,6 +138,22 @@ public Query rangeQuery(Object lowerTerm, Object upperTerm, boolean includeLower
}
return new MatchAllDocsQuery();
}

/**
* Build a type filter
*
* This does not emit a deprecation warning, as it is only called when a type
* has been specified in a REST request and warnings will have already been
* emitted at the REST layer.
*/
public Query typeFilter(String[] types) {
for (String t : types) {
if (Objects.equals(this.type, t)) {
return new MatchAllDocsQuery();
}
}
return new MatchNoDocsQuery();
}
}

private TypeFieldMapper() {
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,6 @@
import java.io.IOException;
import java.io.UncheckedIOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
Expand Down Expand Up @@ -315,8 +314,8 @@ private Query createTypeFilter(String[] types) {
if (mapperService().documentMapper() == null) {
return null;
}
MappedFieldType ft = new TypeFieldMapper.TypeFieldType(mapperService().documentMapper().type());
return ft.termsQuery(Arrays.asList(types), queryShardContext);
TypeFieldMapper.TypeFieldType ft = new TypeFieldMapper.TypeFieldType(mapperService().documentMapper().type());
return ft.typeFilter(types);
}
return null;
}
Expand Down