org.apache.lucene.document.LongField Java Examples

The following examples show how to use org.apache.lucene.document.LongField. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DocumentBuilder.java    From modernmt with Apache License 2.0 6 votes vote down vote up
public static Document newInstance(UUID owner, long memory, LanguageDirection direction, Reader contentReader) {
    Document document = new Document();
    document.add(new StringField(DOC_ID_FIELD, makeId(memory, direction), Field.Store.NO));
    document.add(new LongField(MEMORY_FIELD, memory, Field.Store.YES));

    if (owner != null) {
        document.add(new LongField(OWNER_MSB_FIELD, owner.getMostSignificantBits(), Field.Store.NO));
        document.add(new LongField(OWNER_LSB_FIELD, owner.getLeastSignificantBits(), Field.Store.NO));
    } else {
        document.add(new LongField(OWNER_MSB_FIELD, 0L, Field.Store.NO));
        document.add(new LongField(OWNER_LSB_FIELD, 0L, Field.Store.NO));
    }

    document.add(new CorpusContentField(makeContentFieldName(direction), contentReader));

    return document;
}
 
Example #2
Source File: LuceneSearch.java    From zeppelin with Apache License 2.0 6 votes vote down vote up
/**
 * If paragraph is not null, indexes code in the paragraph, otherwise indexes the notebook name.
 *
 * @param id id of the document, different for Note name and paragraph
 * @param noteName name of the note
 * @param p paragraph
 * @return
 */
private Document newDocument(String id, String noteName, Paragraph p) {
  Document doc = new Document();

  Field pathField = new StringField(ID_FIELD, id, Field.Store.YES);
  doc.add(pathField);
  doc.add(new StringField("title", noteName, Field.Store.YES));

  if (null != p) {
    doc.add(new TextField(SEARCH_FIELD_TEXT, p.getText(), Field.Store.YES));
    if (p.getTitle() != null) {
      doc.add(new TextField(SEARCH_FIELD_TITLE, p.getTitle(), Field.Store.YES));
    }
    Date date = p.getDateStarted() != null ? p.getDateStarted() : p.getDateCreated();
    doc.add(new LongField("modified", date.getTime(), Field.Store.NO));
  } else {
    doc.add(new TextField(SEARCH_FIELD_TEXT, noteName, Field.Store.YES));
  }
  return doc;
}
 
Example #3
Source File: DateFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
  final String dateFormat = properties.get(DATE_FORMAT);
  if (dateFormat == null) {
    throw new RuntimeException("The property [" + DATE_FORMAT + "] can not be null.");
  }
  final String timeUnitStr = properties.get(TIME_UNIT);
  if (timeUnitStr != null) {
    _timeUnit = TimeUnit.valueOf(timeUnitStr.trim().toUpperCase());
  }
  _simpleDateFormat = new ThreadValue<SimpleDateFormat>() {
    @Override
    protected SimpleDateFormat initialValue() {
      return new SimpleDateFormat(dateFormat);
    }
  };
  String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
  if (precisionStepStr != null) {
    _precisionStep = Integer.parseInt(precisionStepStr);
    _typeNotStored = new FieldType(LongField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeNotStored = LongField.TYPE_NOT_STORED;
  }
}
 
Example #4
Source File: LongFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 6 votes vote down vote up
@Override
public void configure(String fieldNameForThisInstance, Map<String, String> properties, Configuration configuration) {
  String precisionStepStr = properties.get(NUMERIC_PRECISION_STEP);
  if (precisionStepStr != null) {
    _precisionStep = Integer.parseInt(precisionStepStr);
    _typeStored = new FieldType(LongField.TYPE_STORED);
    _typeStored.setNumericPrecisionStep(_precisionStep);
    _typeStored.freeze();
    _typeNotStored = new FieldType(LongField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeStored = LongField.TYPE_STORED;
    _typeNotStored = LongField.TYPE_NOT_STORED;
  }
}
 
Example #5
Source File: IndexedField.java    From sql-layer with GNU Affero General Public License v3.0 5 votes vote down vote up
public Field getField(ValueSource value) {
    if (value.isNull()) 
        return null;
    Field.Store store = Field.Store.NO; // Only store hkey.
    switch (fieldType) {
    case INT:
        switch (TInstance.underlyingType(value.getType())) {
        case INT_8:
            return new IntField(name, value.getInt8(), store);
        case INT_16:
            return new IntField(name, value.getInt16(), store);
        case UINT_16:
            return new IntField(name, value.getUInt16(), store);
        case INT_32:
        default:
            return new IntField(name, value.getInt32(), store);
        }
    case LONG:
        return new LongField(name, value.getInt64(), store);
    case FLOAT:
        return new FloatField(name, value.getFloat(), store);
    case DOUBLE:
        return new DoubleField(name, value.getDouble(), store);
    case STRING:
        switch (TInstance.underlyingType(value.getType())) {
        case STRING:
            return new StringField(name, value.getString(), store);
        default:
            {
                StringBuilder str = new StringBuilder();
                value.getType().format(value, AkibanAppender.of(str));
                return new StringField(name, str.toString(), store);
            }
        }
    case TEXT:
        return new TextField(name, value.getString(), store);
    default:
        return null;
    }
}
 
Example #6
Source File: TokenMapperMurmur.java    From stratio-cassandra with Apache License 2.0 5 votes vote down vote up
/** {@inheritDoc} */
@Override
public void addFields(Document document, DecoratedKey partitionKey) {
    Long value = (Long) partitionKey.getToken().getTokenValue();
    Field tokenField = new LongField(FIELD_NAME, value, Store.NO);
    document.add(tokenField);
}
 
Example #7
Source File: DateFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
  String name = getName(family, column.getName());
  long date = parseDate(column.getValue());
  LongField field = new LongField(name, date, _typeNotStored);
  StoredField storedField = new StoredField(name, column.getValue());
  List<Field> fields = new ArrayList<Field>();
  fields.add(field);
  fields.add(storedField);
  if (isSortEnable()) {
    fields.add(new NumericDocValuesField(name, date));
  }
  return fields;
}
 
Example #8
Source File: DateFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) {
  String name = getName(family, column.getName(), subName);
  long date = parseDate(column.getValue());
  LongField field = new LongField(name, date, _typeNotStored);
  if (isSortEnable()) {
    return addSort(name, date, field);
  }
  return makeIterable(field);
}
 
Example #9
Source File: LongFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForColumn(String family, Column column) {
  String name = getName(family, column.getName());
  long value = Long.parseLong(column.getValue());
  LongField field = new LongField(name, value, _typeStored);
  if (isSortEnable()) {
    return addSort(name, value, field);
  }
  return makeIterable(field);
}
 
Example #10
Source File: LongFieldTypeDefinition.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
@Override
public Iterable<? extends Field> getFieldsForSubColumn(String family, Column column, String subName) {
  String name = getName(family, column.getName(), subName);
  long value = Long.parseLong(column.getValue());
  LongField field = new LongField(name, value, _typeNotStored);
  if (isSortEnable()) {
    return addSort(name, value, field);
  }
  return makeIterable(field);
}
 
Example #11
Source File: ColumnMapperDate.java    From stratio-cassandra with Apache License 2.0 4 votes vote down vote up
/** {@inheritDoc} */
@Override
public Field field(String name, Object value) {
    return new LongField(name, indexValue(name, value), STORE);
}