Node newNode = session.getRootNode().addNode("SOMENODE", typeName);
newNode.setProperty("sysName", "X");
// BEFORE SAVING, issue a query that will NOT use the index. The query should not see the transient node ...
String queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE NAME(BASE) = 'SOMENODE'";
Query query = jcrSql2Query(queryStr);
validateQuery().rowCount(0L).useNoIndexes().validate(query, query.execute());
// Now issue a query that will use the index. The query should not see the transient node...
queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE BASE.sysName='X'";
query = jcrSql2Query(queryStr);
validateQuery().rowCount(0L).useIndex("ntsome2sysname").validate(query, query.execute());
// Save the transient data ...
session.save();
waitForIndexes();
// Issue a query that will NOT use the index ...
queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE NAME(BASE) = 'SOMENODE'";
query = jcrSql2Query(queryStr);
validateQuery().rowCount(1L).useNoIndexes().validate(query, query.execute());
// Now issue a query that will use the index.
queryStr = "select BASE.* FROM [" + typeName + "] as BASE WHERE BASE.sysName='X'";
query = jcrSql2Query(queryStr);
validateQuery().rowCount(1L).useIndex("ntsome2sysname").validate(query, query.execute());
registerValueIndex("ntusysname", "nt:unstructured", null, "*", "sysName", PropertyType.STRING);
waitForIndexes();
Node newNode2 = session.getRootNode().addNode("SOMENODE2", "nt:unstructured");
newNode2.setProperty("sysName", "X");
session.save();
waitForIndexes();
// print = true;
queryStr = "select BASE.* FROM [nt:unstructured] as BASE WHERE BASE.sysName='X'";
query = jcrSql2Query(queryStr);
validateQuery().rowCount(2L).validate(query, query.execute());
}