本文整理汇总了Java中org.neo4j.graphdb.index.Index.delete方法的典型用法代码示例。如果您正苦于以下问题:Java Index.delete方法的具体用法?Java Index.delete怎么用?Java Index.delete使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.index.Index
的用法示例。
在下文中一共展示了Index.delete方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: deleteIndex
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void deleteIndex()
{
GraphDatabaseService graphDb = new TestGraphDatabaseFactory().newImpermanentDatabase();
try ( Transaction tx = graphDb.beginTx() )
{
// START SNIPPET: delete
IndexManager index = graphDb.index();
Index<Node> actors = index.forNodes( "actors" );
actors.delete();
// END SNIPPET: delete
tx.success();
}
assertFalse( indexExists( graphDb ) );
graphDb.shutdown();
}
示例2: makeSureAdditionsCanBeRemoved
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
private void makeSureAdditionsCanBeRemoved( boolean restartTx )
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
String key = "name";
String value = "Mattias";
assertNull( index.get( key, value ).getSingle() );
Node node = graphDb.createNode();
index.add( node, key, value );
if ( restartTx )
{
restartTx();
}
assertEquals( node, index.get( key, value ).getSingle() );
index.remove( node, key, value );
assertNull( index.get( key, value ).getSingle() );
restartTx();
assertNull( index.get( key, value ).getSingle() );
node.delete();
index.delete();
}
示例3: makeSureSomeAdditionsCanBeRemoved
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
private void makeSureSomeAdditionsCanBeRemoved( boolean restartTx )
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
String key1 = "name";
String key2 = "title";
String value1 = "Mattias";
assertNull( index.get( key1, value1 ).getSingle() );
assertNull( index.get( key2, value1 ).getSingle() );
Node node = graphDb.createNode();
Node node2 = graphDb.createNode();
index.add( node, key1, value1 );
index.add( node, key2, value1 );
index.add( node2, key1, value1 );
if ( restartTx )
{
restartTx();
}
index.remove( node, key1, value1 );
index.remove( node, key2, value1 );
assertEquals( node2, index.get( key1, value1 ).getSingle() );
assertNull( index.get( key2, value1 ).getSingle() );
assertEquals( node2, index.get( key1, value1 ).getSingle() );
assertNull( index.get( key2, value1 ).getSingle() );
node.delete();
index.delete();
}
示例4: makeSureWildcardQueriesCanBeAsked
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureWildcardQueriesCanBeAsked()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
String key = "name";
String value1 = "neo4j";
String value2 = "nescafe";
Node node1 = graphDb.createNode();
Node node2 = graphDb.createNode();
index.add( node1, key, value1 );
index.add( node2, key, value2 );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.query( key, "neo*" ), contains( node1 ) );
assertThat( index.query( key, "n?o4j" ), contains( node1 ) );
assertThat( index.query( key, "ne*" ), contains( node1, node2 ) );
assertThat( index.query( key + ":neo4j" ), contains( node1 ) );
assertThat( index.query( key + ":neo*" ), contains( node1 ) );
assertThat( index.query( key + ":n?o4j" ), contains( node1 ) );
assertThat( index.query( key + ":ne*" ), contains( node1, node2 ) );
restartTx();
}
index.delete();
}
示例5: makeSureCompositeQueriesCanBeAsked
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureCompositeQueriesCanBeAsked()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
Node neo = graphDb.createNode();
Node trinity = graphDb.createNode();
index.add( neo, "username", "[email protected]" );
index.add( neo, "sex", "male" );
index.add( trinity, "username", "[email protected]" );
index.add( trinity, "sex", "female" );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.query( "username:*@matrix AND sex:male" ), contains( neo ) );
assertThat( index.query( new QueryContext( "username:*@matrix sex:male" ).defaultOperator( Operator.AND ) ), contains( neo ) );
assertThat( index.query( "username:*@matrix OR sex:male" ), contains( neo, trinity ) );
assertThat( index.query( new QueryContext( "username:*@matrix sex:male" ).defaultOperator( Operator.OR ) ), contains( neo, trinity ) );
restartTx();
}
index.delete();
}
示例6: doSomeRandomTestingWithFulltextIndex
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void doSomeRandomTestingWithFulltextIndex(
Index<T> index,
EntityCreator<T> creator )
{
T entity1 = creator.create();
T entity2 = creator.create();
String key = "name";
index.add( entity1, key, "The quick brown fox" );
index.add( entity2, key, "brown fox jumped over" );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, "The quick brown fox" ), contains( entity1 ) );
assertThat( index.get( key, "brown fox jumped over" ), contains( entity2 ) );
assertThat( index.query( key, "quick" ), contains( entity1 ) );
assertThat( index.query( key, "brown" ), contains( entity1, entity2 ) );
assertThat( index.query( key, "quick OR jumped" ), contains( entity1, entity2 ) );
assertThat( index.query( key, "brown AND fox" ), contains( entity1, entity2 ) );
restartTx();
}
index.delete();
}
示例7: canDeleteIndexEvenIfEntitiesAreFoundToBeAbandonedInTheSameTx
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void canDeleteIndexEvenIfEntitiesAreFoundToBeAbandonedInTheSameTx() throws Exception
{
// create and index a node
Index<Node> nodeIndex = graphDb.index().forNodes( "index" );
Node node = graphDb.createNode();
nodeIndex.add( node, "key", "value" );
// make sure to commit the creation of the entry
restartTx();
// delete the node to abandon the index entry
node.delete();
restartTx();
// iterate over all nodes indexed with the key to discover abandoned
for ( @SuppressWarnings( "unused" ) Node hit : nodeIndex.get( "key", "value" ) )
{
;
}
nodeIndex.delete();
restartTx();
}
示例8: main
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
public static void main( String[] args )
{
GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );
Index<Node> index;
Index<Node> index2;
try ( Transaction tx = db.beginTx() )
{
index = db.index().forNodes( "index" );
index2 = db.index().forNodes( "index2" );
Node node = db.createNode();
index.add( node, "key", "value" );
tx.success();
}
try ( Transaction tx = db.beginTx() )
{
index.delete();
index2.add( db.createNode(), "key", "value" );
tx.success();
}
db.shutdown();
System.exit( 0 );
}
示例9: makeSureAdditionsCanBeRead
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void makeSureAdditionsCanBeRead(
Index<T> index, EntityCreator<T> entityCreator )
{
String key = "name";
String value = "Mattias";
assertThat( index.get( key, value ).getSingle(), is( nullValue() ) );
assertThat( index.get( key, value ), isEmpty() );
assertThat( index.query( key, "*" ), isEmpty() );
T entity1 = entityCreator.create();
T entity2 = entityCreator.create();
index.add( entity1, key, value );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, value ), contains( entity1 ) );
assertThat( index.query( key, "*" ), contains( entity1 ) );
assertThat( index.get( key, value ), contains( entity1 ) );
restartTx();
}
index.add( entity2, key, value );
assertThat( index.get( key, value ), contains( entity1, entity2 ) );
restartTx();
assertThat( index.get( key, value ), contains( entity1, entity2 ) );
index.delete();
}
示例10: makeSureThereCanBeMoreThanOneValueForAKeyAndEntity
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
private void makeSureThereCanBeMoreThanOneValueForAKeyAndEntity(
boolean restartTx )
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
String key = "name";
String value1 = "Lucene";
String value2 = "Index";
String value3 = "Rules";
assertThat( index.query( key, "*" ), isEmpty() );
Node node = graphDb.createNode();
index.add( node, key, value1 );
index.add( node, key, value2 );
if ( restartTx )
{
restartTx();
}
index.add( node, key, value3 );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, value1 ), contains( node ) );
assertThat( index.get( key, value2 ), contains( node ) );
assertThat( index.get( key, value3 ), contains( node ) );
assertThat( index.get( key, "whatever" ), isEmpty() );
restartTx();
}
index.delete();
}
示例11: makeSureArrayValuesAreSupported
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureArrayValuesAreSupported()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
String key = "name";
String value1 = "Lucene";
String value2 = "Index";
String value3 = "Rules";
assertThat( index.query( key, "*" ), isEmpty() );
Node node = graphDb.createNode();
index.add( node, key, new String[]{value1, value2, value3} );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, value1 ), contains( node ) );
assertThat( index.get( key, value2 ), contains( node ) );
assertThat( index.get( key, value3 ), contains( node ) );
assertThat( index.get( key, "whatever" ), isEmpty() );
restartTx();
}
index.remove( node, key, new String[]{value2, value3} );
for ( int i = 0; i < 2; i++ )
{
assertThat( index.get( key, value1 ), contains( node ) );
assertThat( index.get( key, value2 ), isEmpty() );
assertThat( index.get( key, value3 ), isEmpty() );
restartTx();
}
index.delete();
}
示例12: testSortByRelevance
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testSortByRelevance()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
Node node1 = graphDb.createNode();
Node node2 = graphDb.createNode();
Node node3 = graphDb.createNode();
index.add( node1, "name", "something" );
index.add( node2, "name", "something" );
index.add( node2, "foo", "yes" );
index.add( node3, "name", "something" );
index.add( node3, "foo", "yes" );
index.add( node3, "bar", "yes" );
restartTx();
IndexHits<Node> hits = index.query(
new QueryContext( "+name:something foo:yes bar:yes" ).sort( Sort.RELEVANCE ) );
assertEquals( node3, hits.next() );
assertEquals( node2, hits.next() );
assertEquals( node1, hits.next() );
assertFalse( hits.hasNext() );
index.delete();
node1.delete();
node2.delete();
node3.delete();
}
示例13: makeSureIndexNamesCanBeRead
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureIndexNamesCanBeRead()
{
beginTx();
assertEquals( 0, graphDb.index().nodeIndexNames().length );
String name1 = "my-index-1";
Index<Node> nodeIndex1 = graphDb.index().forNodes( name1 );
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name1 );
String name2 = "my-index-2";
graphDb.index().forNodes( name2 );
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name1, name2 );
graphDb.index().forRelationships( name1 );
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name1, name2 );
assertContains( Arrays.asList( graphDb.index().relationshipIndexNames() ), name1 );
finishTx( true );
restartTx();
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name1, name2 );
assertContains( Arrays.asList( graphDb.index().relationshipIndexNames() ), name1 );
nodeIndex1.delete();
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name1, name2 );
assertContains( Arrays.asList( graphDb.index().relationshipIndexNames() ), name1 );
finishTx( true );
beginTx();
assertContains( Arrays.asList( graphDb.index().nodeIndexNames() ), name2 );
assertContains( Arrays.asList( graphDb.index().relationshipIndexNames() ), name1 );
finishTx( false );
}
示例14: shouldBeAbleToDeleteAndRecreateIndex
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void shouldBeAbleToDeleteAndRecreateIndex()
{
restartTx();
assertContains( index.query( key, "own" ) );
index.delete();
restartTx();
Index<Node> recreatedIndex = graphDb.index().forNodes( INDEX_NAME, LuceneIndexImplementation.FULLTEXT_CONFIG );
assertNull( recreatedIndex.get( key, value ).getSingle() );
recreatedIndex.add( node, key, value );
restartTx();
assertContains( recreatedIndex.query( key, "own" ), node );
recreatedIndex.delete();
}
示例15: doSomeRandomUseCaseTestingWithExactIndex
import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void doSomeRandomUseCaseTestingWithExactIndex(
Index<T> index, EntityCreator<T> creator )
{
String name = "name";
String mattias = "Mattias Persson";
String title = "title";
String hacker = "Hacker";
assertThat( index.get( name, mattias ), isEmpty() );
T entity1 = creator.create();
T entity2 = creator.create();
assertNull( index.get( name, mattias ).getSingle() );
index.add( entity1, name, mattias );
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertContains( index.query( name, "\"" + mattias + "\"" ), entity1 );
assertContains( index.query( "name:\"" + mattias + "\"" ), entity1 );
assertEquals( entity1, index.get( name, mattias ).getSingle() );
assertContains( index.query( "name", "Mattias*" ), entity1 );
commitTx();
beginTx();
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertThat( index.query( name, "\"" + mattias + "\"" ), contains( entity1 ) );
assertThat( index.query( "name:\"" + mattias + "\"" ), contains( entity1 ) );
assertEquals( entity1, index.get( name, mattias ).getSingle() );
assertThat( index.query( "name", "Mattias*" ), contains( entity1 ) );
commitTx();
beginTx();
index.add( entity2, title, hacker );
index.add( entity1, title, hacker );
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertThat( index.get( title, hacker ), contains( entity1, entity2 ) );
assertContains( index.query( "name:\"" + mattias + "\" OR title:\"" +
hacker + "\"" ), entity1, entity2 );
commitTx();
beginTx();
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertThat( index.get( title, hacker ), contains( entity1, entity2 ) );
assertThat( index.query( "name:\"" + mattias + "\" OR title:\"" + hacker + "\"" ), contains( entity1, entity2 ) );
assertThat( index.query( "name:\"" + mattias + "\" AND title:\"" +
hacker + "\"" ), contains( entity1 ) );
commitTx();
beginTx();
index.remove( entity2, title, hacker );
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertThat( index.get( title, hacker ), contains( entity1 ) );
assertContains( index.query( "name:\"" + mattias + "\" OR title:\"" +
hacker + "\"" ), entity1 );
commitTx();
beginTx();
assertThat( index.get( name, mattias ), contains( entity1 ) );
assertThat( index.get( title, hacker ), contains( entity1 ) );
assertThat( index.query( "name:\"" + mattias + "\" OR title:\"" +
hacker + "\"" ), contains( entity1 ) );
commitTx();
beginTx();
index.remove( entity1, title, hacker );
index.remove( entity1, name, mattias );
index.delete();
commitTx();
}