Skip to content

Commit

Permalink
Core: Remove NestedDocsFilter, because it isn't used and also don't e…
Browse files Browse the repository at this point in the history
…agerly load it in bitset filter cache.

Closes #8414
  • Loading branch information
martijnvg committed Nov 9, 2014
1 parent 1368229 commit 696beb6
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 70 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,6 @@
import org.elasticsearch.index.mapper.MapperService;
import org.elasticsearch.index.mapper.internal.ParentFieldMapper;
import org.elasticsearch.index.mapper.object.ObjectMapper;
import org.elasticsearch.index.search.nested.NestedDocsFilter;
import org.elasticsearch.index.search.nested.NonNestedDocsFilter;
import org.elasticsearch.index.service.IndexService;
import org.elasticsearch.index.service.InternalIndexService;
Expand Down Expand Up @@ -268,7 +267,6 @@ public TerminationHandle warmNewReaders(final IndexShard indexShard, IndexMetaDa

if (hasNested) {
warmUp.add(NonNestedDocsFilter.INSTANCE);
warmUp.add(NestedDocsFilter.INSTANCE);
}

final Executor executor = threadPool.executor(executor());
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -20,22 +20,29 @@
package org.elasticsearch.index.search.nested;

import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term;
import org.apache.lucene.search.DocIdSet;
import org.apache.lucene.search.Filter;
import org.apache.lucene.search.PrefixFilter;
import org.apache.lucene.util.Bits;
import org.apache.lucene.util.BytesRef;
import org.elasticsearch.common.lucene.search.NotFilter;
import org.elasticsearch.index.mapper.internal.TypeFieldMapper;

import java.io.IOException;

/**
* A filter that returns all root (non nested) documents.
*
* Root documents have an unique id, a type and optionally have a _source and other indexed and stored fields.
* A nested document is a sub documents that belong to a root document.
* Nested documents share the unique id and type and optionally the _source with root documents.
*/
public class NonNestedDocsFilter extends Filter {

public static final NonNestedDocsFilter INSTANCE = new NonNestedDocsFilter();

private final Filter filter = new NotFilter(NestedDocsFilter.nestedFilter());
private final Filter filter = new NotFilter(nestedFilter());
private final int hashCode = filter.hashCode();

private NonNestedDocsFilter() {
Expand All @@ -55,4 +62,11 @@ public int hashCode() {
public boolean equals(Object obj) {
return obj == INSTANCE;
}

/**
* @return a filter that returns all nested documents.
*/
private static Filter nestedFilter() {
return new PrefixFilter(new Term(TypeFieldMapper.NAME, new BytesRef("__")));
}
}

0 comments on commit 696beb6

Please sign in to comment.