org.apache.lucene.document.IntField Java Examples

The following examples show how to use org.apache.lucene.document.IntField. 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: IntFieldTypeDefinition.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(IntField.TYPE_STORED);
    _typeStored.setNumericPrecisionStep(_precisionStep);
    _typeStored.freeze();
    _typeNotStored = new FieldType(IntField.TYPE_NOT_STORED);
    _typeNotStored.setNumericPrecisionStep(_precisionStep);
    _typeNotStored.freeze();
  } else {
    _typeStored = IntField.TYPE_STORED;
    _typeNotStored = IntField.TYPE_NOT_STORED;
  }
}
 
Example #2
Source File: Txt2PubmedIdIndexer.java    From bluima with Apache License 2.0 6 votes vote down vote up
@Override
public void process(JCas jCas) throws AnalysisEngineProcessException {
    int pmid = BlueCasUtil.getHeaderIntDocId(jCas);
    if (!BlueCasUtil.isEmptyText(jCas)) {
        // System.out.println("indexing:: " + pmid);
        Document doc = new Document();
        doc.add(new IntField(PMID_FIELD, pmid, Store.YES));
        doc.add(new TextField(CONTENT_FIELD, jCas.getDocumentText(),
                Store.YES));
        doc.add(new TextField(TITLE_FIELD, getTitle(jCas), Store.YES));
        try {
            indexWriter.addDocument(doc);
        } catch (IOException e) {
            throw new AnalysisEngineProcessException(e);
        }
    }
}
 
Example #3
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 #4
Source File: IntFieldTypeDefinition.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());
  int value = Integer.parseInt(column.getValue());
  IntField field = new IntField(name, value, _typeStored);
  if (isSortEnable()) {
    return addSort(name, value, field);
  }
  return makeIterable(field);
}
 
Example #5
Source File: IntFieldTypeDefinition.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);
  int value = Integer.parseInt(column.getValue());
  IntField field = new IntField(name, value, _typeNotStored);
  if (isSortEnable()) {
    return addSort(name, value, field);
  }
  return makeIterable(field);
}
 
Example #6
Source File: TestingPagingCollector.java    From incubator-retired-blur with Apache License 2.0 5 votes vote down vote up
private static IndexReader getReaderFlatScore(int length) throws Exception {
  _directory = new RAMDirectory();
  IndexWriter indexWriter = new IndexWriter(_directory, new IndexWriterConfig(LUCENE_VERSION, new KeywordAnalyzer()));
  for (int i = 0; i < length; i++) {
    Document document = new Document();
    document.add(new StringField("f1", "value", Store.NO));
    document.add(new IntDocValuesField("index", i));
    document.add(new IntField("index", i, Store.YES));
    indexWriter.addDocument(document);
  }
  indexWriter.close();
  return DirectoryReader.open(_directory);
}
 
Example #7
Source File: DocumentWrap.java    From openbd-core with GNU General Public License v3.0 4 votes vote down vote up
public void setSize( int size ){
	if ( size > 0 )
		doc.add( new IntField( SIZE, size, Field.Store.YES) );
}
 
Example #8
Source File: AbstractLuceneIndexCreator.java    From Palmetto with GNU Affero General Public License v3.0 4 votes vote down vote up
protected void addDocumentLength(Document document, String docLengthFieldName, FieldType docLengthFieldType,
        int documentLength) {
    document.add(new IntField(docLengthFieldName, documentLength, docLengthFieldType));
}
 
Example #9
Source File: TableShardCountCollapserTest.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
private static Document getDoc(int i) {
  Document document = new Document();
  document.add(new IntField("id", i, Store.YES));
  return document;
}
 
Example #10
Source File: BaseDirectoryTestSuite.java    From incubator-retired-blur with Apache License 2.0 4 votes vote down vote up
private Document getDoc(int i) {
  Document document = new Document();
  document.add(new IntField("id", i, Store.YES));
  return document;
}