Refine search
public void index(final StandardProvenanceEventRecord record, final IndexWriter indexWriter, final Integer blockIndex) throws IOException { final Document doc = new Document(); addField(doc, SearchableFields.FlowFileUUID, record.getFlowFileUuid(), Store.NO); addField(doc, SearchableFields.Filename, record.getAttribute(CoreAttributes.FILENAME.key()), Store.NO); if (!doc.getFields().isEmpty()) { doc.add(new LongField(SearchableFields.LineageStartDate.getSearchableFieldName(), record.getLineageStartDate(), Store.NO)); doc.add(new LongField(SearchableFields.EventTime.getSearchableFieldName(), record.getEventTime(), Store.NO)); doc.add(new LongField(SearchableFields.FileSize.getSearchableFieldName(), record.getFileSize(), Store.NO)); doc.add(new StringField(FieldNames.STORAGE_FILENAME, storageFilename, Store.YES)); doc.add(new LongField(FieldNames.STORAGE_FILE_OFFSET, record.getStorageByteOffset(), Store.YES)); } else { doc.add(new IntField(FieldNames.BLOCK_INDEX, blockIndex, Store.YES)); doc.add(new LongField(SearchableFields.Identifier.getSearchableFieldName(), record.getEventId(), Store.YES));
doc = new Document(); Field docidField = new StringField(DOCID, docid, Field.Store.YES); doc.add(docidField); } else if (hits.scoreDocs.length > 1) { throw new IllegalArgumentException("More than one document found for document id: " + docid); for (IndexableField field : doc.getFields()) { if (field.stringValue().startsWith(GEOID)) { geofields.put(field.name(), ctx.readShape(field.stringValue().substring(GEOID.length()))); Field field = null; if (AttributeUtil.isWholeNumber((Number) add.value)) { field = new LongField(add.key, ((Number) add.value).longValue(), Field.Store.YES); } else { //double or float field = new DoubleField(add.key, ((Number) add.value).doubleValue(), Field.Store.YES);
@Override public void addLongNumericField(long value, String name, int precisionStep, SerializableStore store, boolean indexed, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) { final LongField numField = new LongField( name, value, getStore( store ) ); numField.setBoost( boost ); getLuceneDocument().add( numField ); }
public static IndexableField instantiateField( String key, Object value, FieldType fieldType ) { IndexableField field; if ( value instanceof Number ) { Number number = (Number) value; if ( value instanceof Long ) { field = new LongField( key, number.longValue(), Store.YES ); } else if ( value instanceof Float ) { field = new FloatField( key, number.floatValue(), Store.YES ); } else if ( value instanceof Double ) { field = new DoubleField( key, number.doubleValue(), Store.YES ); } else { field = new IntField( key, number.intValue(), Store.YES ); } } else { field = new Field( key, value.toString(), fieldType ); } return field; }
public Document convert(final ProvenanceEventRecord record, final StorageSummary persistedEvent) { final Document doc = new Document(); addField(doc, SearchableFields.FlowFileUUID, record.getFlowFileUuid()); addField(doc, SearchableFields.Filename, record.getAttribute(CoreAttributes.FILENAME.key())); if (!doc.getFields().isEmpty()) { doc.add(new LongField(SearchableFields.LineageStartDate.getSearchableFieldName(), record.getLineageStartDate(), Store.NO)); doc.add(new LongField(SearchableFields.EventTime.getSearchableFieldName(), record.getEventTime(), Store.NO)); doc.add(new LongField(SearchableFields.FileSize.getSearchableFieldName(), record.getFileSize(), Store.NO));
@Override public void addLongNumericField(long value, String name, int precisionStep, SerializableStore store, boolean indexed, float boost, boolean omitNorms, boolean omitTermFreqAndPositions) { final LongField numField = new LongField( name, value, getStore( store ) ); numField.setBoost( boost ); getLuceneDocument().add( numField ); }
public static Field tsField(long timestamp, FieldType fieldType) { return new LongField(CF_TS_INDEXED, timestamp, fieldType); }
private Document generateIndexDoc(Record record, Map<String, IndexType> columns) throws IOException, AnalyticsIndexException { Document doc = new Document(); doc.add(new StringField(INDEX_ID_INTERNAL_FIELD, record.getId(), Store.YES)); doc.add(new LongField(INDEX_INTERNAL_TIMESTAMP_FIELD, record.getTimestamp(), Store.NO)); /* make the best effort to store in the given timestamp, or else, * fall back to a compatible format, or else, lastly, string */ String name; for (Map.Entry<String, IndexType> entry : columns.entrySet()) { name = entry.getKey(); this.checkAndAddDocEntry(doc, entry.getValue(), name, record.getValue(name)); } return doc; }
Document doc = new Document(); .toString(), Field.Store.NO); doc.add(refererField); doc.add(updateActionField); Field timestampField = new LongField(ServiceDocument.FIELD_NAME_UPDATE_TIME_MICROS, s.documentUpdateTimeMicros, this.longStoredField); doc.add(timestampField); Field expirationTimeMicrosField = new LongField( ServiceDocument.FIELD_NAME_EXPIRATION_TIME_MICROS, s.documentExpirationTimeMicros, this.longStoredField); Field versionField = new LongField(ServiceDocument.FIELD_NAME_VERSION, s.documentVersion, this.longStoredField);
@Override protected void onExecute(Document doc, XsObject root, XsObject current, LogicletContext ctx, ExecuteWatcher watcher) { String field = PropertiesConstants.transform(ctx, $field, ""); long value = PropertiesConstants.transform(ctx, $value, 0L); if (StringUtils.isNotEmpty(field)){ doc.add(new NumericDocValuesField(field,value)); if (store){ doc.add(new LongField(field,value,Field.Store.YES)); } } }
/** {@inheritDoc} */ @Override public Optional<Field> indexedField(String name, Long value) { return Optional.of(new LongField(name, value, STORE)); }
/** * Build Lucene document from article. * * @param article Article * @return Document */ private org.apache.lucene.document.Document getDocumentFromArticle(Article article) { // Index character offsets for the highlighter FieldType fieldType = new FieldType(TextField.TYPE_STORED); fieldType.setIndexOptions(IndexOptions.DOCS_AND_FREQS_AND_POSITIONS_AND_OFFSETS); // Building document org.apache.lucene.document.Document document = new org.apache.lucene.document.Document(); document.add(new StringField("id", article.getId(), Field.Store.YES)); document.add(new StringField("url", article.getUrl(), Field.Store.YES)); document.add(new LongField("date", article.getPublicationDate().getTime(), Field.Store.YES)); document.add(new Field("title", article.getTitle(), fieldType)); document.add(new Field("description", article.getDescription(), fieldType)); return document; } }
/** * Adds a file to index with {@link IndexWriter}. * @param file will be indexed by the function */ public void indexFile(final File file) { FileInputStream fis = getInputStream(file); Document doc = documentFactory.createDocument(); // Add the path of the file as a field named "path". Use a field that is indexed (i.e. searchable), but don't tokenize // the field into separate words and don't index term frequency or positional information: Field pathField = new StringField(fieldName, file.getAbsolutePath(), Field.Store.YES); doc.add(pathField); // Add the last modified date of the file a field named "modified". // Use a LongField that is indexed (i.e. efficiently filterable with NumericRangeFilter). doc.add(new LongField("modified", file.lastModified(), Field.Store.NO)); // Add the contents of the file to a field named "contents". // If that's not the case searching for special characters will fail. BufferedReader bufferedReader; try { bufferedReader = bufferedReaderFactory.createReader(fis); doc.add(new Field("contents", bufferedReader, TextField.TYPE_NOT_STORED)); addDocument(file, doc); fis.close(); } catch (IOException e) { logger.error(" caught a " + e.getClass() + "\n with message: " + e.getMessage()); } }
public static Field longField(String name, String value) { return new LongField(name, Long.parseLong(value), Field.Store.NO); }
public static Document convertChronoDocumentToLuceneDocument(final ChronoIndexDocument chronoDocument) { checkNotNull(chronoDocument, "Precondition violation - argument 'chronoDocument' must not be NULL!"); Document document = new Document(); document.add(new StringField(DOCUMENT_FIELD_ID, chronoDocument.getDocumentId(), Store.YES)); document.add(new StringField(DOCUMENT_FIELD_BRANCH, chronoDocument.getBranch(), Store.YES)); document.add(new StringField(DOCUMENT_FIELD_KEYSPACE, chronoDocument.getKeyspace(), Store.YES)); document.add(new StringField(DOCUMENT_FIELD_KEY, chronoDocument.getKey(), Store.YES)); document.add(new StringField(DOCUMENT_FIELD_INDEX_NAME, chronoDocument.getIndexName(), Store.YES)); Object indexedValue = chronoDocument.getIndexedValue(); if (indexedValue instanceof String) { String string = (String) indexedValue; document.add(new StringField(DOCUMENT_FIELD_INDEXED_VALUE, string, Store.YES)); document.add(new StringField(DOCUMENT_FIELD_INDEXED_VALUE_CI, string.toLowerCase(), Store.YES)); } else if (indexedValue instanceof Long) { long value = (long) indexedValue; document.add(new LongField(DOCUMENT_FIELD_INDEXED_VALUE_LONG, value, Store.YES)); } else if (indexedValue instanceof Double) { double value = (double) indexedValue; document.add(new DoubleField(DOCUMENT_FIELD_INDEXED_VALUE_DOUBLE, value, Store.YES)); } else { throw new IllegalStateException("Unknown index value type: '" + indexedValue.getClass().getName() + "'!"); } document.add(new LongField(DOCUMENT_FIELD_VALID_FROM, chronoDocument.getValidFromTimestamp(), Store.YES)); document.add(new LongField(DOCUMENT_FIELD_VALID_TO, chronoDocument.getValidToTimestamp(), Store.YES)); return document; }
public void addDocumentField(Document tmp, JsonElement jsonValue) { if ( jsonValue == null || jsonValue.isJsonNull() ) { return; } switch ( fieldType ) { case INTEGER: tmp.add( new IntField( absoluteName, jsonValue.getAsInt(), Store.NO ) ); break; case LONG: tmp.add( new LongField( absoluteName, jsonValue.getAsLong(), Store.NO ) ); break; case FLOAT: tmp.add( new FloatField( absoluteName, jsonValue.getAsFloat(), Store.NO ) ); break; case DOUBLE: tmp.add( new DoubleField( absoluteName, jsonValue.getAsDouble(), Store.NO ) ); break; case UNKNOWN_NUMERIC: throw LOG.unexpectedNumericEncodingType( rootTypeMetadata.getType(), absoluteName ); case BOOLEAN: tmp.add( new StringField( absoluteName, String.valueOf( jsonValue.getAsBoolean() ), Store.NO ) ); break; default: tmp.add( new StringField( absoluteName, jsonValue.getAsString(), Store.NO ) ); break; } }