コード例 #1
0
 @Override
 public DocIdSet getDocIdSet(IndexReader reader) throws IOException {
   DocSet boundingBoxDocSet = null;
   if (boundingBoxFilter != null) {
     DocIdSet docIdSet = boundingBoxFilter.getDocIdSet(reader);
     if (docIdSet == null) {
       return null;
     }
     boundingBoxDocSet = DocSets.convert(reader, docIdSet);
   }
   final GeoPointFieldData fieldData =
       (GeoPointFieldData) fieldDataCache.cache(GeoPointFieldDataType.TYPE, reader, fieldName);
   GeoDistanceRangeDocSet distDocSet =
       new GeoDistanceRangeDocSet(
           reader.maxDoc(),
           fieldData,
           fixedSourceDistance,
           distanceBoundingCheck,
           inclusiveLowerPoint,
           inclusiveUpperPoint);
   if (boundingBoxDocSet == null) {
     return distDocSet;
   } else {
     return new AndDocSet(ImmutableList.of(boundingBoxDocSet, distDocSet));
   }
 }
コード例 #2
0
 @Override
 protected void doSetNextReader(IndexReader reader, int docBase) throws IOException {
   fieldData = (ShortFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName);
   if (script != null) {
     script.setNextReader(reader);
   }
 }
コード例 #3
0
ファイル: IndexCache.java プロジェクト: scompt/elasticsearch
 @Override
 public void close() throws ElasticSearchException {
   filterCache.close();
   fieldDataCache.close();
   idCache.close();
   queryParserCache.close();
   if (clusterService != null) {
     clusterService.remove(this);
   }
 }
コード例 #4
0
 @Override
 protected void doSetNextReader(IndexReader reader, int docBase) throws IOException {
   if (current != null) {
     missing += current.counts[0];
     if (current.values.length > 1) {
       aggregators.add(current);
     }
   }
   fieldData = (LongFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName);
   current = new ReaderAggregator(fieldData);
 }
コード例 #5
0
ファイル: IndexCache.java プロジェクト: scompt/elasticsearch
 public void clearUnreferenced() {
   filterCache.clearUnreferenced();
   fieldDataCache.clearUnreferenced();
   idCache.clearUnreferenced();
 }
コード例 #6
0
ファイル: IndexCache.java プロジェクト: scompt/elasticsearch
 public void clear() {
   filterCache.clear();
   fieldDataCache.clear();
   idCache.clear();
   queryParserCache.clear();
 }
コード例 #7
0
ファイル: IndexCache.java プロジェクト: scompt/elasticsearch
 public void clear(IndexReader reader) {
   filterCache.clear(reader);
   fieldDataCache.clear(reader);
   idCache.clear(reader);
 }
コード例 #8
0
  public TermsShortFacetCollector(
      String facetName,
      String fieldName,
      int size,
      TermsFacet.ComparatorType comparatorType,
      boolean allTerms,
      SearchContext context,
      String scriptLang,
      String script,
      Map<String, Object> params) {
    super(facetName);
    this.fieldDataCache = context.fieldDataCache();
    this.size = size;
    this.comparatorType = comparatorType;
    this.numberOfShards = context.numberOfShards();

    MapperService.SmartNameFieldMappers smartMappers = context.mapperService().smartName(fieldName);
    if (smartMappers == null || !smartMappers.hasMapper()) {
      throw new ElasticSearchIllegalArgumentException(
          "Field ["
              + fieldName
              + "] doesn't have a type, can't run terms short facet collector on it");
    } else {
      // add type filter if there is exact doc mapper associated with it
      if (smartMappers.hasDocMapper()) {
        setFilter(context.filterCache().cache(smartMappers.docMapper().typeFilter()));
      }

      if (smartMappers.mapper().fieldDataType() != FieldDataType.DefaultTypes.SHORT) {
        throw new ElasticSearchIllegalArgumentException(
            "Field ["
                + fieldName
                + "] is not of short type, can't run terms short facet collector on it");
      }

      this.indexFieldName = smartMappers.mapper().names().indexName();
      this.fieldDataType = smartMappers.mapper().fieldDataType();
    }

    if (script != null) {
      this.script =
          new SearchScript(context.lookup(), scriptLang, script, params, context.scriptService());
    } else {
      this.script = null;
    }

    if (this.script == null) {
      aggregator = new StaticAggregatorValueProc(popFacets());
    } else {
      aggregator = new AggregatorValueProc(popFacets(), this.script);
    }

    if (allTerms) {
      try {
        for (IndexReader reader : context.searcher().subReaders()) {
          ShortFieldData fieldData =
              (ShortFieldData) fieldDataCache.cache(fieldDataType, reader, indexFieldName);
          fieldData.forEachValue(aggregator);
        }
      } catch (Exception e) {
        throw new FacetPhaseExecutionException(facetName, "failed to load all terms", e);
      }
    }
  }