Java 类org.neo4j.graphdb.index.AutoIndexer 实例源码

项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testNodeAutoIndexFromAPISanity()
{
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "test_uuid" );
    autoIndexer.setEnabled( true );
    assertEquals( 1, autoIndexer.getAutoIndexedProperties().size() );
    assertTrue( autoIndexer.getAutoIndexedProperties().contains(
            "test_uuid" ) );
    newTransaction();

    Node node1 = graphDb.createNode();
    node1.setProperty( "test_uuid", "node1" );
    Node node2 = graphDb.createNode();
    node2.setProperty( "test_uuid", "node2" );

    newTransaction();

    assertEquals(
            node1,
            autoIndexer.getAutoIndex().get( "test_uuid", "node1" ).getSingle() );
    assertEquals(
            node2,
            autoIndexer.getAutoIndex().get( "test_uuid", "node2" ).getSingle() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testAutoIndexesReportReadOnly()
{
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    try ( Transaction tx = graphDb.beginTx() )
    {
        assertFalse( autoIndexer.getAutoIndex().isWriteable() );
        tx.success();
    }
    autoIndexer.startAutoIndexingProperty( "test_uuid" );
    autoIndexer.setEnabled( true );
    try ( Transaction tx = graphDb.beginTx() )
    {
        assertFalse( autoIndexer.getAutoIndex().isWriteable() );
        tx.success();
    }
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testConfigAndAPICompatibility()
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "nodeProp1, nodeProp2" );
    config.put( GraphDatabaseSettings.relationship_keys_indexable.name(), "relProp1, relProp2" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    config.put( GraphDatabaseSettings.relationship_auto_indexing.name(), "true" );
    startDb();

    assertTrue( graphDb.index().getNodeAutoIndexer().isEnabled() );
    assertTrue( graphDb.index().getRelationshipAutoIndexer().isEnabled() );

    AutoIndexer<Node> autoNodeIndexer = graphDb.index().getNodeAutoIndexer();
    // Start auto indexing a new and an already auto indexed
    autoNodeIndexer.startAutoIndexingProperty( "nodeProp1" );
    autoNodeIndexer.startAutoIndexingProperty( "nodeProp3" );
    assertEquals( 3, autoNodeIndexer.getAutoIndexedProperties().size() );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp1" ) );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp2" ) );
    assertTrue( autoNodeIndexer.getAutoIndexedProperties().contains(
            "nodeProp3" ) );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testDefaulIfOffIsForEverything()
{
    graphDb.index().getNodeAutoIndexer().setEnabled( true );
    newTransaction();
    Node node1 = graphDb.createNode();
    node1.setProperty( "testProp", "node1" );
    node1.setProperty( "testProp1", "node1" );
    Node node2 = graphDb.createNode();
    node2.setProperty( "testProp", "node2" );
    node2.setProperty( "testProp1", "node2" );

    newTransaction();
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    assertFalse( autoIndexer.getAutoIndex().get( "testProp", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "testProp1", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "testProp", "node2" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "testProp1", "node2" ).hasNext() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testDefaultIsOffIfExplicit() throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "nodeProp1, nodeProp2" );
    config.put( GraphDatabaseSettings.relationship_keys_indexable.name(), "relProp1, relProp2" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "false" );
    config.put( GraphDatabaseSettings.relationship_auto_indexing.name(), "false" );
    startDb();

    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "testProp" );
    newTransaction();

    Node node1 = graphDb.createNode();
    node1.setProperty( "nodeProp1", "node1" );
    node1.setProperty( "nodeProp2", "node1" );
    node1.setProperty( "testProp", "node1" );

    newTransaction();

    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp1", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp2", "node1" ).hasNext() );
    assertFalse( autoIndexer.getAutoIndex().get( "testProp", "node1" ).hasNext() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testDeletingNodeRemovesItFromAutoIndex() throws Exception
{
    AutoIndexer<Node> nodeAutoIndexer = graphDb.index().getNodeAutoIndexer();
    nodeAutoIndexer.startAutoIndexingProperty( "foo" );
    nodeAutoIndexer.setEnabled( true );

    newTransaction();

    Node node1 = graphDb.createNode();
    node1.setProperty( "foo", "bar" );

    newTransaction();

    assertThat( graphDb.index().forNodes( "node_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 1 ) );

    node1.delete();

    newTransaction();

    assertThat( graphDb.index().forNodes( "node_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 0 ) );
}
项目:xo-neo4j-query    文件:LuceneQueryTest.java   
@Before
public void setup() {
    final XOManager xoManager = getXoManager();
    xoManager.currentTransaction().begin();

    // enable legacy auto indexing
    final Neo4jDatastoreSession datastoreSession = xoManager.getDatastoreSession(Neo4jDatastoreSession.class);
    final GraphDatabaseService graphDatabaseService = datastoreSession.getGraphDatabaseService();
    final AutoIndexer<Node> nodeAutoIndexer = graphDatabaseService.index().getNodeAutoIndexer();
    nodeAutoIndexer.startAutoIndexingProperty("name");
    nodeAutoIndexer.setEnabled(true);

    final A a = xoManager.create(A.class);
    a.setName("foo");

    xoManager.currentTransaction().commit();
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testChangesAreVisibleInTransaction()
{
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "nodeProp" );
    autoIndexer.setEnabled( true );

    newTransaction();

    Node node1 = graphDb.createNode();
    node1.setProperty( "nodeProp", "nodePropValue" );
    node1.setProperty( "nodePropNonIndexable", "valueWhatever" );
    ReadableIndex<Node> nodeIndex = autoIndexer.getAutoIndex();
    assertEquals( node1,
            nodeIndex.get( "nodeProp", "nodePropValue" ).getSingle() );

    newTransaction();

    Node node2 = graphDb.createNode();
    node2.setProperty( "nodeProp", "nodePropValue2" );
    assertEquals( node2,
            nodeIndex.get( "nodeProp", "nodePropValue2" ).getSingle() );
    node2.setProperty( "nodeProp", "nodePropValue3" );
    assertEquals( node2,
            nodeIndex.get( "nodeProp", "nodePropValue3" ).getSingle() );
    node2.removeProperty( "nodeProp" );
    assertFalse( nodeIndex.get( "nodeProp", "nodePropValue2" ).hasNext() );
    assertFalse( nodeIndex.get( "nodeProp", "nodePropValue3" ).hasNext() );

    newTransaction();

    assertEquals( node1,
            nodeIndex.get( "nodeProp", "nodePropValue" ).getSingle() );
    assertFalse( nodeIndex.get( "nodeProp", "nodePropValue2" ).hasNext() );
    assertFalse( nodeIndex.get( "nodeProp", "nodePropValue3" ).hasNext() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testRelationshipAutoIndexFromAPISanity()
{
    final String propNameToIndex = "test";
    AutoIndexer<Relationship> autoIndexer = graphDb.index().getRelationshipAutoIndexer();
    autoIndexer.startAutoIndexingProperty( propNameToIndex );
    autoIndexer.setEnabled( true );
    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    Node node3 = graphDb.createNode();

    Relationship rel12 = node1.createRelationshipTo( node2,
            DynamicRelationshipType.withName( "DYNAMIC" ) );
    Relationship rel23 = node2.createRelationshipTo( node3,
            DynamicRelationshipType.withName( "DYNAMIC" ) );

    rel12.setProperty( propNameToIndex, "rel12" );
    rel23.setProperty( propNameToIndex, "rel23" );

    newTransaction();

    assertEquals(
            rel12,
            autoIndexer.getAutoIndex().get( propNameToIndex,
                    "rel12" ).getSingle() );
    assertEquals(
            rel23,
            autoIndexer.getAutoIndex().get( propNameToIndex,
                    "rel23" ).getSingle() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testDefaultIsOff()
{
    newTransaction();
    Node node1 = graphDb.createNode();
    node1.setProperty( "testProp", "node1" );

    newTransaction();
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    assertFalse( autoIndexer.getAutoIndex().get( "testProp", "node1" ).hasNext() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testStartStopAutoIndexing() throws Exception
{
    stopDb();
    config = new HashMap<>();
    config.put( GraphDatabaseSettings.node_keys_indexable.name(), "propName" );
    config.put( GraphDatabaseSettings.node_auto_indexing.name(), "true" );
    // Now only node properties named propName should be indexed.
    startDb();

    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    assertTrue( autoIndexer.isEnabled() );

    autoIndexer.setEnabled( false );
    assertFalse( autoIndexer.isEnabled() );
    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.setProperty( "propName", "node" );
    newTransaction();

    assertFalse( autoIndexer.getAutoIndex().get( "nodeProp1", "node1" ).hasNext() );
    autoIndexer.setEnabled( true );
    node2.setProperty( "propName", "node" );

    newTransaction();

    assertEquals( node2,
            autoIndexer.getAutoIndex().get( "propName", "node" ).getSingle() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testStopMonitoringProperty()
{
    AutoIndexer<Node> autoIndexer = graphDb.index().getNodeAutoIndexer();
    autoIndexer.setEnabled( true );
    autoIndexer.startAutoIndexingProperty( "propName" );
    newTransaction();
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    node1.setProperty( "propName", "node" );
    newTransaction();
    assertEquals(
            node1,
            autoIndexer.getAutoIndex().get( "propName", "node" ).getSingle() );
    newTransaction();
    // Setting just another property to autoindex
    autoIndexer.startAutoIndexingProperty( "propName2" );
    autoIndexer.stopAutoIndexingProperty( "propName" );
    node2.setProperty( "propName", "propValue" );
    Node node3 = graphDb.createNode();
    node3.setProperty( "propName2", "propValue" );
    newTransaction();
    // Now node2 must be not there, node3 must be there and node1 should not have been touched
    assertEquals(
            node1,
            autoIndexer.getAutoIndex().get( "propName", "node" ).getSingle() );
    assertEquals(
            node3,
            autoIndexer.getAutoIndex().get( "propName2", "propValue" ).getSingle() );
    // Now, since only propName2 is autoindexed, every other should be
    // removed when touched, such as node1's propName
    node1.setProperty( "propName", "newValue" );
    newTransaction();
    assertFalse( autoIndexer.getAutoIndex().get( "propName", "newValue" ).hasNext() );
}
项目:neo4j-lucene5-index    文件:TestAutoIndexing.java   
@Test
public void testRemoveRelationshipRemovesDocument()
{
    AutoIndexer<Relationship> autoIndexer = graphDb.index().getRelationshipAutoIndexer();
    autoIndexer.startAutoIndexingProperty( "foo" );
    autoIndexer.setEnabled( true );

    newTransaction();

    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    Relationship rel = node1.createRelationshipTo( node2, DynamicRelationshipType.withName( "foo" ) );
    rel.setProperty( "foo", "bar" );

    newTransaction();

    assertThat( graphDb.index().forRelationships( "relationship_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 1 ) );

    newTransaction();

    rel.delete();

    newTransaction();

    assertThat( graphDb.index().forRelationships( "relationship_auto_index" ).query( "_id_:*" ).size(),
            equalTo( 0 ) );
}
项目:SciGraph    文件:Neo4jModule.java   
private static void setupIndex(AutoIndexer<?> index, Collection<String> properties) {
  for (String property : properties) {
    index.startAutoIndexingProperty(property);
  }
  index.setEnabled(true);

}
项目:octotron_core    文件:Neo4jIndex.java   
@Override
public void EnableObjectIndex(String name)
{
    AutoIndexer<Node> node_auto_indexer =
        graph.GetInnerIndex().getNodeAutoIndexer();

    node_auto_indexer.startAutoIndexingProperty(name);
    node_auto_indexer.setEnabled(true);
}
项目:octotron_core    文件:Neo4jIndex.java   
@Override
public void DisableObjectIndex(String name)
{
    AutoIndexer<Node> node_auto_indexer =
        graph.GetInnerIndex().getNodeAutoIndexer();

    node_auto_indexer.stopAutoIndexingProperty(name);
}
项目:octotron_core    文件:Neo4jIndex.java   
@Override
public void EnableLinkIndex(String name)
{
    AutoIndexer<Relationship> rel_auto_indexer =
        graph.GetInnerIndex().getRelationshipAutoIndexer();

    rel_auto_indexer.startAutoIndexingProperty(name);
    rel_auto_indexer.setEnabled(true);
}
项目:octotron_core    文件:Neo4jIndex.java   
@Override
public void DisableLinkIndex(String name)
{
    AutoIndexer<Relationship> rel_auto_indexer =
        graph.GetInnerIndex().getRelationshipAutoIndexer();

    rel_auto_indexer.stopAutoIndexingProperty(name);
}
项目:neo4j-timestamp    文件:TimestampKernelExtension.java   
void setupTimestampIndexing(AutoIndexer<? extends PropertyContainer> autoIndexer) {
  autoIndexer.startAutoIndexingProperty(TimestampTransactionEventHandler.MODIFIED_TIMESTAMP_PROPERTY_NAME);
  if (this.addCreated){
    autoIndexer.startAutoIndexingProperty(TimestampTransactionEventHandler.CREATED_TIMESTAMP_PROPERTY_NAME);        
  }
  autoIndexer.setEnabled(true);
}
项目:SciGraph    文件:OwlPostprocessorTest.java   
void enableIndexing() {
  AutoIndexer<Node> nodeIndex = graphDb.index().getNodeAutoIndexer();
  nodeIndex.startAutoIndexingProperty(CommonProperties.IRI);
  nodeIndex.setEnabled(true);
}
项目:neo4j-mobile-android    文件:IndexManagerImpl.java   
public AutoIndexer<Node> getNodeAutoIndexer()
{
    return nodeAutoIndexer;
}