public ODocument getConfiguration() { return delegate.getConfiguration(); }
private boolean hasIndexClass(OIndex<?> idx) { final ODocument metadata = idx.getMetadata(); return (metadata != null && metadata.field(OrientIndex.CONFIG_CLASSNAME) != null) // compatibility with versions earlier 1.6.3 || idx.getConfiguration().field(OrientIndex.CONFIG_CLASSNAME) != null; }
protected OrientIndex(final OrientBaseGraph orientGraph, final OIndex<?> rawIndex) { this.graph = orientGraph; this.underlying = rawIndex instanceof OIndexTxAwareMultiValue ? rawIndex : new OIndexTxAwareMultiValue( orientGraph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) rawIndex); load(rawIndex.getConfiguration()); }
protected OrientIndex(final OrientBaseGraph orientGraph, final OIndex<?> rawIndex) { this.graph = orientGraph; this.underlying = rawIndex instanceof OIndexTxAwareMultiValue ? rawIndex : new OIndexTxAwareMultiValue( orientGraph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) rawIndex); final ODocument metadata = rawIndex.getMetadata(); if (metadata == null) { load(rawIndex.getConfiguration()); } else load(metadata); }
private void create(final String indexName, final Class<? extends Element> indexClass, OType iKeyType) { this.indexClass = indexClass; if (iKeyType == null) iKeyType = OType.STRING; // CREATE THE MAP this.underlying = new OIndexTxAwareMultiValue(graph.getRawGraph(), (OIndex<Collection<OIdentifiable>>) graph.getRawGraph() .getMetadata().getIndexManager() .createIndex(indexName, OClass.INDEX_TYPE.NOTUNIQUE.toString(), new OSimpleKeyIndexDefinition(iKeyType), null, null)); final String className; if (Vertex.class.isAssignableFrom(indexClass)) className = VERTEX; else if (Edge.class.isAssignableFrom(indexClass)) className = EDGE; else className = indexClass.getName(); // CREATE THE CONFIGURATION FOR THE NEW INDEX underlying.getConfiguration().field(CONFIG_CLASSNAME, className); }
if (idx.getConfiguration().field( OrientIndex.CONFIG_CLASSNAME) != null)
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final CompositeLuceneIndex annotation) { db.getMetadata().getIndexManager().reload(); final String name = Strings.emptyToNull(annotation.name().trim()); Preconditions.checkArgument(name != null, "Index name required"); final String model = descriptor.schemeClass; final OClass clazz = db.getMetadata().getSchema().getClass(model); final OIndex<?> classIndex = clazz.getClassIndex(name); final OClass.INDEX_TYPE type = OClass.INDEX_TYPE.FULLTEXT; final String[] fields = annotation.fields(); if (!descriptor.initialRegistration && classIndex != null) { final IndexValidationSupport support = new IndexValidationSupport(classIndex, logger); support.checkTypeCompatible(type); support.checkFieldsCompatible(fields); final boolean correct = support .isIndexSigns(classIndex.getConfiguration().field("algorithm"), getAnalyzer(classIndex)) .matchRequiredSigns(type, OLuceneIndexFactory.LUCENE_ALGORITHM, annotation.analyzer().getName()); if (!correct) { support.dropIndex(db); } else { // index ok return; } } final ODocument metadata = createMetadata(annotation); SchemeUtils.command(db, "create index %s on %s (%s) %s engine %s metadata %s", name, model, Joiner.on(',').join(fields), type.name(), OLuceneIndexFactory.LUCENE_ALGORITHM, metadata.toJSON()); logger.info("Lucene fulltext index '{}' ({} [{}]) created", name, model, Joiner.on(',').join(fields)); }
private void updateIndexEntries(ODocument iDocument) { iDocument = checkForLoading(iDocument); final OClass cls = iDocument.getSchemaClass(); if (cls == null) return; final Collection<OIndex<?>> indexes = (Collection<OIndex<?>>) getDatabase().getMetadata().getIndexManager().getIndexes(); if (!indexes.isEmpty()) { final Set<String> dirtyFields = new HashSet<String>(Arrays.asList(iDocument.getDirtyFields())); if (!dirtyFields.isEmpty()) { for (final OIndex<?> index : indexes) { if (index.getInternal() instanceof OLuceneIndex && index.getConfiguration().field("metadata") != null) { if (index.getDefinition() instanceof OCompositeIndexDefinition) processCompositeIndexUpdate(index, dirtyFields, iDocument); else processSingleIndexUpdate(index, dirtyFields, iDocument); if (iDocument.isTrackingChanges()) { iDocument.setTrackingChanges(false); iDocument.setTrackingChanges(true); } } } } } }
private boolean isIndexCorrect(final IndexValidationSupport support, final OClass.INDEX_TYPE type, final FulltextIndex annotation) { final OIndex classIndex = support.getIndex(); final ODocument metadata = classIndex.getConfiguration(); final Iterable<String> field = metadata.field(STOP_WORDS); return support .isIndexSigns(metadata.field(INDEX_RADIX), metadata.field(IGNORE_CHARS), metadata.field(SEPARATOR_CHARS), metadata.field(MIN_WORD_LENGTH), Sets.newHashSet(field)) .matchRequiredSigns(type, annotation.indexRadix(), annotation.ignoreChars(), annotation.separatorChars(), annotation.minWordLength(), Sets.newHashSet(annotation.stopWords())); }
@Override public Object call(OrientBaseGraph g) { try { final OIndexManager indexManager = getRawGraph().getMetadata().getIndexManager(); final OIndex index = indexManager.getIndex(indexName); ODocument metadata = index.getConfiguration().field("metadata"); String recordMapIndexName = null; if (metadata != null) { recordMapIndexName = metadata.field(OrientIndex.CONFIG_RECORD_MAP_NAME); } indexManager.dropIndex(indexName); if (recordMapIndexName != null) getRawGraph().getMetadata().getIndexManager().dropIndex(recordMapIndexName); saveIndexConfiguration(); return null; } catch (Exception e) { g.rollback(); throw new RuntimeException(e.getMessage(), e); } } }, "drop index '", indexName, "'");
@Override public void afterRegistration(final ODatabaseObject db, final SchemeDescriptor descriptor, final Field field, final LuceneIndex annotation) { db.getMetadata().getIndexManager().reload(); final String property = field.getName(); final String model = descriptor.schemeClass; final String name = MoreObjects.firstNonNull( Strings.emptyToNull(annotation.name().trim()), model + '.' + property); final OClass clazz = db.getMetadata().getSchema().getClass(model); final OIndex<?> classIndex = clazz.getClassIndex(name); final OClass.INDEX_TYPE type = OClass.INDEX_TYPE.FULLTEXT; if (!descriptor.initialRegistration && classIndex != null) { final IndexValidationSupport support = new IndexValidationSupport(classIndex, logger); support.checkTypeCompatible(type); support.checkFieldsCompatible(property); final boolean correct = support .isIndexSigns(classIndex.getConfiguration().field("algorithm"), getAnalyzer(classIndex)) .matchRequiredSigns(type, OLuceneIndexFactory.LUCENE_ALGORITHM, annotation.value().getName()); if (!correct) { support.dropIndex(db); } else { // index ok return; } } final ODocument metadata = createMetadata(annotation); SchemeUtils.command(db, "create index %s on %s (%s) %s engine %s metadata %s", name, model, property, type.name(), OLuceneIndexFactory.LUCENE_ALGORITHM, metadata.toJSON()); logger.info("Lucene fulltext index '{}' ({} [{}]) created", name, model, property); }
OGlobalConfiguration.INDEX_IGNORE_NULL_VALUES_DEFAULT.setValue(oldValue); if (blueprintsIndexClass != null) { ODocument configuration = index.getConfiguration(); configuration.field("blueprintsIndexClass", blueprintsIndexClass); indexManager.save();
final OIndexMetadata indexMetadata = indexToRecreate.getInternal().loadMetadata(indexToRecreate.getConfiguration());
OIndexMetadata oldIndexMetadata = oldIndex.getInternal().loadMetadata(oldIndex.getConfiguration());
writer.writeAttribute(4, true, "metadata", metadata); final ODocument configuration = index.getConfiguration(); if (configuration.field("blueprintsIndexClass") != null) writer.writeAttribute(4, true, "blueprintsIndexClass", configuration.field("blueprintsIndexClass"));