It seems that automatic indexing behaves differently between a tx commit 
and an nonTx commit.  I have included my test.

In the results.png "abraham" is created with graph transaction.  The 
"lincoln" entry is created a with a graph non-transaction.

For some reason the index never automatically updates in a transaction 
commit, it only on updates during a non-transaction commit.

Any advice would be appreciated.  Perhaps this is a setting or I can call a 
method to update the index after the transaction is successful?

Thanks,

Abe

-- 

--- 
You received this message because you are subscribed to the Google Groups 
"OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
For more options, visit https://groups.google.com/d/optout.
package index;

import static org.junit.Assert.assertTrue;

import java.util.Iterator;

import org.junit.Before;
import org.junit.Test;

import com.orientechnologies.orient.core.collate.OCaseInsensitiveCollate;
import com.orientechnologies.orient.core.metadata.schema.OClass;
import com.orientechnologies.orient.core.metadata.schema.OType;
import com.tinkerpop.blueprints.Vertex;
import com.tinkerpop.blueprints.impls.orient.OrientGraph;
import com.tinkerpop.blueprints.impls.orient.OrientGraphNoTx;
import com.tinkerpop.blueprints.impls.orient.OrientVertex;
import com.tinkerpop.blueprints.impls.orient.OrientVertexType;
import com.tinkerpop.blueprints.impls.orient.OrientVertexType.OrientVertexProperty;

public class IndexOnSave {


	@Before
	public void setUp() throws Exception {

		OrientGraphNoTx orientGraphNoTx = new OrientGraphNoTx("plocal:/oriendb/databases/IndexTestDB", "admin", "admin");

		// create index if new db
		if (orientGraphNoTx.getVertexType("IndexTest") == null) {
			OrientVertexType vertexType = orientGraphNoTx.createVertexType("IndexTest", "V");
			OrientVertexProperty nameProperty = vertexType.createProperty("name", OType.STRING);
			nameProperty.createIndex(OClass.INDEX_TYPE.FULLTEXT);
			nameProperty.setCollate(OCaseInsensitiveCollate.NAME);
			orientGraphNoTx.shutdown();
		} else {
			orientGraphNoTx.shutdown();
		}
		
		//create initial noTx data
		orientGraphNoTx = new OrientGraphNoTx("plocal:/oriendb/databases/IndexTestDB", "admin", "admin");
		orientGraphNoTx.addVertex("class:IndexTest", "name", "Lincoln").save();
		orientGraphNoTx.commit();
		orientGraphNoTx.shutdown();
		
		
		//create initial tx data
		OrientGraph graph = new OrientGraph("plocal:/oriendb/databases/IndexTestDB");
		graph.addVertex("class:IndexTest", "name", "Abraham").save();
		graph.commit();
		graph.shutdown();

	}

	@Test
	public void testTX() {

		OrientGraph graph = new OrientGraph("plocal:/oriendb/databases/IndexTestDB");

		OrientVertex addedVertex = graph.addVertex("class:IndexTest", "name", "Abraham");
		System.out.println(" Tx " + addedVertex.getId());
		graph.commit();

		Iterator<Vertex> it = graph.getVertices("IndexTest.name", "Abr").iterator();

		int count = 0;
		while (it.hasNext()) {
			Vertex vertex = (Vertex) it.next();
			System.out.println(vertex.getProperty("name"));
		}

		graph.shutdown();
		assertTrue(1 >= count);

	}

	@Test
	public void testNoTX() {

		OrientGraphNoTx orientGraphNoTx = new OrientGraphNoTx("plocal:/oriendb/databases/IndexTestDB");

		OrientVertex addedVertex = orientGraphNoTx.addVertex("class:IndexTest", "name", "Lincoln");
		System.out.println(" NoTx " + addedVertex.getId());
		orientGraphNoTx.commit();

		Iterator<Vertex> it = orientGraphNoTx.getVertices("IndexTest.name", "Lin").iterator();

		int count = 0;
		while (it.hasNext()) {
			count ++;
			Vertex vertex = (Vertex) it.next();
			System.out.println(vertex.getProperty("name"));
		}
		
		orientGraphNoTx.shutdown();
		assertTrue(1 >= count);

	}

}

Reply via email to