com.orientechnologies.orient.core.index.OIndexes Java Examples

The following examples show how to use com.orientechnologies.orient.core.index.OIndexes. 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: OLuceneIndexPlugin.java    From orientdb-lucene with Apache License 2.0 5 votes vote down vote up
@Override
public void startup() {
  super.startup();
  Orient.instance().addDbLifecycleListener(this);

  OIndexes.registerFactory(new OLuceneIndexFactory(true));
  OSQLEngine.registerOperator(new OLuceneTextOperator());
  OSQLEngine.registerOperator(new OLuceneWithinOperator());
  OSQLEngine.registerOperator(new OLuceneNearOperator());
  OLogManager.instance().info(this, "Lucene index plugin installed and active. Lucene version: %s",
      OLuceneIndexManagerAbstract.LUCENE_VERSION);
}
 
Example #2
Source File: ODocumentWrapper.java    From divide with Apache License 2.0 4 votes vote down vote up
public <B extends TransientObject> ODocumentWrapper(B b){
    super();

    String className = b.getObjectType();
    this.setAllowChainedAccess(true);
    this.setLazyLoad(false);


    // dirty unreliable hack to add HighLanderIndexFactory to the list.
    if(!OIndexes.getIndexTypes().contains(ID))
    try {
        HighLanderIndexFactory f = new HighLanderIndexFactory();
        Set<OIndexFactory> set = new HashSet<OIndexFactory>();
        Iterator<OIndexFactory> ite = OIndexes.getAllFactories();
        while (ite.hasNext()) {
            set.add(ite.next());
        }
        set.add(f);
        ReflectionUtils.setFinalStatic(ReflectionUtils.getClassField(OIndexes.class, "FACTORIES"), set);
    } catch (Exception e) {
        throw new RuntimeException("Unable to create OrientDBWrapper");
    }

    if(getDatabase().getClusterIdByName(className) == -1){
        OClass object = getDatabase().getMetadata().getSchema().getOrCreateClass(className);
        object.createProperty(indexAttribute, OType.STRING)
                .setMandatory(true)
                .setNotNull(true)
                .setReadonly(true);
        object.createIndex(className, ID, indexAttribute);
        getDatabase().getMetadata().getSchema().save();
    }

    Map user = b.getUserData();
    Map meta = b.getMetaData();

    field(indexAttribute, b.getObjectKey(), OType.STRING);
    field("user_data", user);
    field("meta_data", meta);
    super.setClassNameIfExists(className);

    System.out.println("DB: " + getDatabase().getName() + " : " + this.getClassName() + " : " + getDatabase().getClusterIdByName(className));
}