org.apache.lucene.index.DocValuesType#NONE源码实例Demo

下面列出了org.apache.lucene.index.DocValuesType#NONE 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: lucene-solr   文件: PointVectorStrategy.java
/**
 * Create a new instance configured with the provided FieldType options. See {@link #DEFAULT_FIELDTYPE}.
 * a field type is used to articulate the desired options (namely pointValues, docValues, stored).  Legacy numerics
 * is configurable this way too.
 */
public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) {
  super(ctx, fieldNamePrefix);
  this.fieldNameX = fieldNamePrefix+SUFFIX_X;
  this.fieldNameY = fieldNamePrefix+SUFFIX_Y;

  int numPairs = 0;
  if ((this.hasStored = fieldType.stored())) {
    numPairs++;
  }
  if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {
    numPairs++;
  }
  if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
    numPairs++;
  }
  this.fieldsLen = numPairs * 2;
}
 
源代码2 项目: lucene-solr   文件: TestBlockWriter.java
private static FieldInfo getMockFieldInfo(String fieldName, int number) {
  return new FieldInfo(fieldName,
      number,
      false,
      false,
      true,
      IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS,
      DocValuesType.NONE,
      -1,
      Collections.emptyMap(),
      0,
      0,
      0,
      true
  );
}
 
源代码3 项目: lucene-solr   文件: TestSTBlockReader.java
private static FieldInfo mockFieldInfo(String fieldName, int number) {
  return new FieldInfo(fieldName,
      number,
      false,
      false,
      true,
      IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS,
      DocValuesType.NONE,
      -1,
      Collections.emptyMap(),
      0,
      0,
      0,
      false
  );
}
 
源代码4 项目: lucene-solr   文件: Lucene50FieldInfosFormat.java
private static DocValuesType getDocValuesType(IndexInput input, byte b) throws IOException {
  switch(b) {
  case 0:
    return DocValuesType.NONE;
  case 1:
    return DocValuesType.NUMERIC;
  case 2:
    return DocValuesType.BINARY;
  case 3:
    return DocValuesType.SORTED;
  case 4:
    return DocValuesType.SORTED_SET;
  case 5:
    return DocValuesType.SORTED_NUMERIC;
  default:
    throw new CorruptIndexException("invalid docvalues byte: " + b, input);
  }
}
 
源代码5 项目: lucene-solr   文件: Lucene60FieldInfosFormat.java
private static DocValuesType getDocValuesType(IndexInput input, byte b) throws IOException {
  switch(b) {
  case 0:
    return DocValuesType.NONE;
  case 1:
    return DocValuesType.NUMERIC;
  case 2:
    return DocValuesType.BINARY;
  case 3:
    return DocValuesType.SORTED;
  case 4:
    return DocValuesType.SORTED_SET;
  case 5:
    return DocValuesType.SORTED_NUMERIC;
  default:
    throw new CorruptIndexException("invalid docvalues byte: " + b, input);
  }
}
 
源代码6 项目: lucene-solr   文件: TermVectorLeafReader.java
public TermVectorLeafReader(String field, Terms terms) {
  fields = new Fields() {
    @Override
    public Iterator<String> iterator() {
      return Collections.singletonList(field).iterator();
    }

    @Override
    public Terms terms(String fld) throws IOException {
      if (!field.equals(fld)) {
        return null;
      }
      return terms;
    }

    @Override
    public int size() {
      return 1;
    }
  };

  IndexOptions indexOptions;
  if (!terms.hasFreqs()) {
    indexOptions = IndexOptions.DOCS;
  } else if (!terms.hasPositions()) {
    indexOptions = IndexOptions.DOCS_AND_FREQS;
  } else if (!terms.hasOffsets()) {
    indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS;
  } else {
    indexOptions = IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS;
  }
  FieldInfo fieldInfo = new FieldInfo(field, 0,
                                      true, true, terms.hasPayloads(),
                                      indexOptions, DocValuesType.NONE, -1, Collections.emptyMap(), 0, 0, 0, false);
  fieldInfos = new FieldInfos(new FieldInfo[]{fieldInfo});
}
 
源代码7 项目: lucene-solr   文件: CollapsingQParserPlugin.java
ReaderWrapper(LeafReader leafReader, String field) {
  super(leafReader);

  // TODO can we just do "field" and not bother with the other fields?
  List<FieldInfo> newInfos = new ArrayList<>(in.getFieldInfos().size());
  for (FieldInfo fieldInfo : in.getFieldInfos()) {
    if (fieldInfo.name.equals(field)) {
      FieldInfo f = new FieldInfo(fieldInfo.name,
          fieldInfo.number,
          fieldInfo.hasVectors(),
          fieldInfo.hasNorms(),
          fieldInfo.hasPayloads(),
          fieldInfo.getIndexOptions(),
          DocValuesType.NONE,
          fieldInfo.getDocValuesGen(),
          fieldInfo.attributes(),
          fieldInfo.getPointDimensionCount(),
          fieldInfo.getPointIndexDimensionCount(),
          fieldInfo.getPointNumBytes(),
          fieldInfo.isSoftDeletesField());
      newInfos.add(f);
    } else {
      newInfos.add(fieldInfo);
    }
  }
  FieldInfos infos = new FieldInfos(newInfos.toArray(new FieldInfo[newInfos.size()]));
  this.fieldInfos = infos;
}
 
源代码8 项目: lucene-solr   文件: BBoxStrategy.java
/**
 * Creates this strategy.
 * {@code fieldType} is used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL
 * field too. Search requires pointValues (or legacy numerics), and relevancy requires docValues. If these features
 * aren't needed then disable them.
 */
public BBoxStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) {
  super(ctx, fieldNamePrefix);
  field_bbox = fieldNamePrefix;
  field_minX = fieldNamePrefix + SUFFIX_MINX;
  field_maxX = fieldNamePrefix + SUFFIX_MAXX;
  field_minY = fieldNamePrefix + SUFFIX_MINY;
  field_maxY = fieldNamePrefix + SUFFIX_MAXY;
  field_xdl = fieldNamePrefix + SUFFIX_XDL;

  fieldType.freeze();
  this.optionsFieldType = fieldType;

  int numQuads = 0;
  if ((this.hasStored = fieldType.stored())) {
    numQuads++;
  }
  if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {
    numQuads++;
  }
  if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
    numQuads++;
  }

  if (hasPointVals) { // if we have an index...
    xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED);
    xdlFieldType.setIndexOptions(IndexOptions.DOCS);
    xdlFieldType.freeze();
  } else {
    xdlFieldType = null;
  }

  this.fieldsLen = numQuads * 4 + (xdlFieldType != null ? 1 : 0);
}
 
源代码9 项目: lucene-solr   文件: TestDocValuesFieldSources.java
public void test() throws IOException {
  for (DocValuesType type : DocValuesType.values()) {
    if (type != DocValuesType.SORTED_SET && type != DocValuesType.NONE) {
      test(type);
    }
  }
}
 
源代码10 项目: lucene-solr   文件: PointVectorStrategy.java
/**
 * Create a new instance configured with the provided FieldType options. See {@link #DEFAULT_FIELDTYPE}.
 * a field type is used to articulate the desired options (namely pointValues, docValues, stored).  Legacy numerics
 * is configurable this way too.
 */
public PointVectorStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) {
  super(ctx, fieldNamePrefix);
  this.fieldNameX = fieldNamePrefix+SUFFIX_X;
  this.fieldNameY = fieldNamePrefix+SUFFIX_Y;

  int numPairs = 0;
  if ((this.hasStored = fieldType.stored())) {
    numPairs++;
  }
  if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {
    numPairs++;
  }
  if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
    numPairs++;
  }
  if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType)fieldType).numericType() != null) {
    if (hasPointVals) {
      throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive");
    }
    final LegacyFieldType legacyType = (LegacyFieldType) fieldType;
    if (legacyType.numericType() != LegacyNumericType.DOUBLE) {
      throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType());
    }
    numPairs++;
    legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED);
    legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep());
    legacyNumericFieldType.freeze();
  } else {
    legacyNumericFieldType = null;
  }
  this.fieldsLen = numPairs * 2;
}
 
源代码11 项目: lucene-solr   文件: PerFieldMergeState.java
FilterFieldInfos(FieldInfos src, Collection<String> filterFields) {
  // Copy all the input FieldInfo objects since the field numbering must be kept consistent
  super(toArray(src));

  boolean hasVectors = false;
  boolean hasProx = false;
  boolean hasPayloads = false;
  boolean hasOffsets = false;
  boolean hasFreq = false;
  boolean hasNorms = false;
  boolean hasDocValues = false;
  boolean hasPointValues = false;

  this.filteredNames = new HashSet<>(filterFields);
  this.filtered = new ArrayList<>(filterFields.size());
  for (FieldInfo fi : src) {
    if (this.filteredNames.contains(fi.name)) {
      this.filtered.add(fi);
      hasVectors |= fi.hasVectors();
      hasProx |= fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS) >= 0;
      hasFreq |= fi.getIndexOptions() != IndexOptions.DOCS;
      hasOffsets |= fi.getIndexOptions().compareTo(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS) >= 0;
      hasNorms |= fi.hasNorms();
      hasDocValues |= fi.getDocValuesType() != DocValuesType.NONE;
      hasPayloads |= fi.hasPayloads();
      hasPointValues |= (fi.getPointDimensionCount() != 0);
    }
  }

  this.filteredHasVectors = hasVectors;
  this.filteredHasProx = hasProx;
  this.filteredHasPayloads = hasPayloads;
  this.filteredHasOffsets = hasOffsets;
  this.filteredHasFreq = hasFreq;
  this.filteredHasNorms = hasNorms;
  this.filteredHasDocValues = hasDocValues;
  this.filteredHasPointValues = hasPointValues;
}
 
源代码12 项目: lucene-solr   文件: PerFieldDocValuesFormat.java
@Override
public void merge(MergeState mergeState) throws IOException {
  Map<DocValuesConsumer, Collection<String>> consumersToField = new IdentityHashMap<>();

  // Group each consumer by the fields it handles
  for (FieldInfo fi : mergeState.mergeFieldInfos) {
    if (fi.getDocValuesType() == DocValuesType.NONE) {
      continue;
    }
    // merge should ignore current format for the fields being merged
    DocValuesConsumer consumer = getInstance(fi, true);
    Collection<String> fieldsForConsumer = consumersToField.get(consumer);
    if (fieldsForConsumer == null) {
      fieldsForConsumer = new ArrayList<>();
      consumersToField.put(consumer, fieldsForConsumer);
    }
    fieldsForConsumer.add(fi.name);
  }

  // Delegate the merge to the appropriate consumer
  PerFieldMergeState pfMergeState = new PerFieldMergeState(mergeState);
  try {
    for (Map.Entry<DocValuesConsumer, Collection<String>> e : consumersToField.entrySet()) {
      e.getKey().merge(pfMergeState.apply(e.getValue()));
    }
  } finally {
    pfMergeState.reset();
  }
}
 
源代码13 项目: lucene-solr   文件: PerFieldDocValuesFormat.java
public FieldsReader(final SegmentReadState readState) throws IOException {

      // Init each unique format:
      boolean success = false;
      try {
        // Read field name -> format name
        for (FieldInfo fi : readState.fieldInfos) {
          if (fi.getDocValuesType() != DocValuesType.NONE) {
            final String fieldName = fi.name;
            final String formatName = fi.getAttribute(PER_FIELD_FORMAT_KEY);
            if (formatName != null) {
              // null formatName means the field is in fieldInfos, but has no docvalues!
              final String suffix = fi.getAttribute(PER_FIELD_SUFFIX_KEY);
              if (suffix == null) {
                throw new IllegalStateException("missing attribute: " + PER_FIELD_SUFFIX_KEY + " for field: " + fieldName);
              }
              DocValuesFormat format = DocValuesFormat.forName(formatName);
              String segmentSuffix = getFullSegmentSuffix(readState.segmentSuffix, getSuffix(formatName, suffix));
              if (!formats.containsKey(segmentSuffix)) {
                formats.put(segmentSuffix, format.fieldsProducer(new SegmentReadState(readState, segmentSuffix)));
              }
              fields.put(fieldName, formats.get(segmentSuffix));
            }
          }
        }
        success = true;
      } finally {
        if (!success) {
          IOUtils.closeWhileHandlingException(formats.values());
        }
      }
    }
 
源代码14 项目: lucene-solr   文件: LatLonDocValuesField.java
/** helper: checks a fieldinfo and throws exception if its definitely not a LatLonDocValuesField */
static void checkCompatible(FieldInfo fieldInfo) {
  // dv properties could be "unset", if you e.g. used only StoredField with this same name in the segment.
  if (fieldInfo.getDocValuesType() != DocValuesType.NONE && fieldInfo.getDocValuesType() != TYPE.docValuesType()) {
    throw new IllegalArgumentException("field=\"" + fieldInfo.name + "\" was indexed with docValuesType=" + fieldInfo.getDocValuesType() + 
                                       " but this type has docValuesType=" + TYPE.docValuesType() + 
                                       ", is the field really a LatLonDocValuesField?");
  }
}
 
源代码15 项目: lucene-solr   文件: XYDocValuesField.java
/** helper: checks a fieldinfo and throws exception if its definitely not a XYDocValuesField */
static void checkCompatible(FieldInfo fieldInfo) {
  // dv properties could be "unset", if you e.g. used only StoredField with this same name in the segment.
  if (fieldInfo.getDocValuesType() != DocValuesType.NONE && fieldInfo.getDocValuesType() != TYPE.docValuesType()) {
    throw new IllegalArgumentException("field=\"" + fieldInfo.name + "\" was indexed with docValuesType=" + fieldInfo.getDocValuesType() + 
                                       " but this type has docValuesType=" + TYPE.docValuesType() + 
                                       ", is the field really a XYDocValuesField?");
  }
}
 
源代码16 项目: lucene-solr   文件: FieldCacheImpl.java
@Override
protected BitsEntry createValue(LeafReader reader, CacheKey key) throws IOException {
  final String field = key.field;
  final Parser parser = (Parser) key.custom;
  FieldInfo fieldInfo = reader.getFieldInfos().fieldInfo(field);
  if (fieldInfo.getDocValuesType() != DocValuesType.NONE) {
    return createValueDocValues(reader, field);
  } else if (parser instanceof PointParser) {
    return createValuePoints(reader, field);
  } else {
    return createValuePostings(reader, field);
  }
}
 
private UninvertingReader.Type getUninversionType(FieldInfo fi) {
  SchemaField sf = schema.getFieldOrNull(fi.name);
  
  if (null != sf &&
      sf.hasDocValues() &&
      fi.getDocValuesType() == DocValuesType.NONE &&
      fi.getIndexOptions() != IndexOptions.NONE) {
    return sf.getType().getUninversionType(sf);
  } else {
    return null;
  }
}
 
源代码18 项目: lucene-solr   文件: BBoxStrategy.java
/**
 * Creates this strategy.
 * {@code fieldType} is used to customize the indexing options of the 4 number fields, and to a lesser degree the XDL
 * field too. Search requires pointValues (or legacy numerics), and relevancy requires docValues. If these features
 * aren't needed then disable them.
 */
public BBoxStrategy(SpatialContext ctx, String fieldNamePrefix, FieldType fieldType) {
  super(ctx, fieldNamePrefix);
  field_bbox = fieldNamePrefix;
  field_minX = fieldNamePrefix + SUFFIX_MINX;
  field_maxX = fieldNamePrefix + SUFFIX_MAXX;
  field_minY = fieldNamePrefix + SUFFIX_MINY;
  field_maxY = fieldNamePrefix + SUFFIX_MAXY;
  field_xdl = fieldNamePrefix + SUFFIX_XDL;

  fieldType.freeze();
  this.optionsFieldType = fieldType;

  int numQuads = 0;
  if ((this.hasStored = fieldType.stored())) {
    numQuads++;
  }
  if ((this.hasDocVals = fieldType.docValuesType() != DocValuesType.NONE)) {
    numQuads++;
  }
  if ((this.hasPointVals = fieldType.pointDimensionCount() > 0)) {
    numQuads++;
  }
  if (fieldType.indexOptions() != IndexOptions.NONE && fieldType instanceof LegacyFieldType && ((LegacyFieldType)fieldType).numericType() != null) {
    if (hasPointVals) {
      throw new IllegalArgumentException("pointValues and LegacyNumericType are mutually exclusive");
    }
    final LegacyFieldType legacyType = (LegacyFieldType) fieldType;
    if (legacyType.numericType() != LegacyNumericType.DOUBLE) {
      throw new IllegalArgumentException(getClass() + " does not support " + legacyType.numericType());
    }
    numQuads++;
    legacyNumericFieldType = new LegacyFieldType(LegacyDoubleField.TYPE_NOT_STORED);
    legacyNumericFieldType.setNumericPrecisionStep(legacyType.numericPrecisionStep());
    legacyNumericFieldType.freeze();
  } else {
    legacyNumericFieldType = null;
  }

  if (hasPointVals || legacyNumericFieldType != null) { // if we have an index...
    xdlFieldType = new FieldType(StringField.TYPE_NOT_STORED);
    xdlFieldType.setIndexOptions(IndexOptions.DOCS);
    xdlFieldType.freeze();
  } else {
    xdlFieldType = null;
  }

  this.fieldsLen = numQuads * 4 + (xdlFieldType != null ? 1 : 0);
}
 
源代码19 项目: lucene-solr   文件: SchemaField.java
@Override
public DocValuesType docValuesType() {
  return DocValuesType.NONE;
}
 
源代码20 项目: lucene-solr   文件: RealTimeGetComponent.java
/**
 * Converts a SolrInputDocument to SolrDocument, using an IndexSchema instance.
 *
 * @param sdoc The input document.
 * @param schema The index schema.
 * @param forInPlaceUpdate Whether the document is being used for an in place update,
 *                         see {@link DocumentBuilder#toDocument(SolrInputDocument, IndexSchema, boolean, boolean)}
 */
public static SolrDocument toSolrDoc(SolrInputDocument sdoc, IndexSchema schema, boolean forInPlaceUpdate) {
  // TODO what about child / nested docs?
  // TODO: do something more performant than this double conversion
  Document doc = DocumentBuilder.toDocument(sdoc, schema, forInPlaceUpdate, true);

  // copy the stored fields only
  Document out = new Document();
  for (IndexableField f : doc.getFields()) {
    if (f.fieldType().stored()) {
      out.add(f);
    } else if (f.fieldType().docValuesType() != DocValuesType.NONE) {
      SchemaField schemaField = schema.getFieldOrNull(f.name());
      if (schemaField != null && !schemaField.stored() && schemaField.useDocValuesAsStored()) {
        out.add(f);
      }
    } else {
      log.debug("Don't know how to handle field {}", f);
    }
  }

  SolrDocument solrDoc = toSolrDoc(out, schema);

  // add child docs
  for(SolrInputField solrInputField: sdoc) {
    if(solrInputField.getFirstValue() instanceof SolrInputDocument) {
      // is child doc
      Object val = solrInputField.getValue();
      Iterator<SolrDocument> childDocs = solrInputField.getValues().stream()
          .map(x -> toSolrDoc((SolrInputDocument) x, schema)).iterator();
      if(val instanceof Collection) {
        // add as collection even if single element collection
        solrDoc.setField(solrInputField.getName(), Lists.newArrayList(childDocs));
      } else {
        // single child doc
        solrDoc.setField(solrInputField.getName(), childDocs.next());
      }
    }
  }

  return solrDoc;
}