@Test
public void shouldUseSingleColumnNodePathIndexInQueryAgainstSameNodeType() throws Exception {
registerValueIndex("pathIndex", "nt:unstructured", "Node path index", "*", "jcr:path", PropertyType.PATH);
Node book1 = session().getRootNode().addNode("myFirstBook");
book1.addMixin("mix:title");
book1.setProperty("jcr:title", "The Title");
Node book2 = session().getRootNode().addNode("mySecondBook");
book2.addMixin("mix:title");
book2.setProperty("jcr:title", "A Different Title");
Node other = book2.addNode("chapter");
other.setProperty("propA", "a value for property A");
other.setProperty("jcr:title", "The Title");
session.save();
Query query = jcrSql2Query("SELECT * FROM [nt:unstructured] WHERE [jcr:path] = '/myFirstBook'");
validateQuery().rowCount(1L).useIndex("NodeByPath").considerIndex("pathIndex").validate(query, query.execute());
query = jcrSql2Query("SELECT * FROM [nt:unstructured] WHERE [jcr:path] LIKE '/my%Book'");
validateQuery().rowCount(2L).useNoIndexes().validate(query, query.execute());
query = jcrSql2Query("SELECT * FROM [nt:unstructured] WHERE [jcr:path] > '/mySecondBook'");
validateQuery().rowCount(1L).useIndex("pathIndex").validate(query, query.execute());
query = jcrSql2Query("SELECT * FROM [nt:unstructured] WHERE PATH() > '/mySecondBook'");
validateQuery().rowCount(1L).useIndex("pathIndex").validate(query, query.execute());
}