当前位置: 首页>>代码示例>>Java>>正文


Java Index.add方法代码示例

本文整理汇总了Java中org.neo4j.graphdb.index.Index.add方法的典型用法代码示例。如果您正苦于以下问题:Java Index.add方法的具体用法?Java Index.add怎么用?Java Index.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.neo4j.graphdb.index.Index的用法示例。


在下文中一共展示了Index.add方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: testSortingWithTopHitsInPartCommittedPartLocal

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testSortingWithTopHitsInPartCommittedPartLocal()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.FULLTEXT_CONFIG );
    Node first = graphDb.createNode();
    Node second = graphDb.createNode();
    Node third = graphDb.createNode();
    Node fourth = graphDb.createNode();
    String key = "key";

    index.add( third, key, "ccc" );
    index.add( second, key, "bbb" );
    restartTx();
    index.add( fourth, key, "ddd" );
    index.add( first, key, "aaa" );

    assertContainsInOrder( index.query( key, new QueryContext( "*" ).sort( key ) ), first, second, third, fourth );
    assertContainsInOrder( index.query( key, new QueryContext( "*" ).sort( key ).top( 2 ) ), first, second );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:20,代码来源:TestLuceneIndex.java

示例2: testScoring

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testScoring()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.FULLTEXT_CONFIG );
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    String key = "text";
    // Where the heck did I get this sentence from?
    index.add( node1, key, "a time where no one was really awake" );
    index.add( node2, key, "once upon a time there was" );
    restartTx();

    IndexHits<Node> hits = index.query( key, new QueryContext( "once upon a time was" ).sort( Sort.RELEVANCE ) );
    Node hit1 = hits.next();
    float score1 = hits.currentScore();
    Node hit2 = hits.next();
    float score2 = hits.currentScore();
    assertEquals( node2, hit1 );
    assertEquals( node1, hit2 );
    assertTrue( "Score 1 (" + score1 + ") should have been higher than score 2 (" + score2 + ")", score1 > score2 );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:TestLuceneIndex.java

示例3: 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();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:21,代码来源:TestLuceneIndex.java

示例4: testCombinedHitsSizeProblem

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testCombinedHitsSizeProblem()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
    Node node1 = graphDb.createNode();
    Node node2 = graphDb.createNode();
    Node node3 = graphDb.createNode();
    String key = "key";
    String value = "value";
    index.add( node1, key, value );
    index.add( node2, key, value );
    restartTx();
    index.add( node3, key, value );
    IndexHits<Node> hits = index.get( key, value );
    assertEquals( 3, hits.size() );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:17,代码来源:TestLuceneIndex.java

示例5: shouldNotFindValueDeletedInSameTx

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void shouldNotFindValueDeletedInSameTx()
{
    Index<Node> nodeIndex = graphDb.index().forNodes( "size-after-removal" );
    Node node = graphDb.createNode();
    nodeIndex.add( node, "key", "value" );
    restartTx();

    nodeIndex.remove( node );
    for ( int i = 0; i < 2; i++ )
    {
        IndexHits<Node> hits = nodeIndex.get( "key", "value" );
        assertEquals( 0, hits.size() );
        assertNull( hits.getSingle() );
        hits.close();
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:19,代码来源:TestLuceneIndex.java

示例6: makeSureFulltextIndexCanBeCaseSensitive

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureFulltextIndexCanBeCaseSensitive()
{
    Index<Node> index = nodeIndex( MapUtil.stringMap(
            new HashMap<>( LuceneIndexImplementation.FULLTEXT_CONFIG ),
                    "to_lower_case", "false" ) );
    Node node = graphDb.createNode();
    String key = "name";
    String value = "Mattias Persson";
    index.add( node, key, value );
    for ( int i = 0; i < 2; i++ )
    {
        assertThat( index.query( "name", "[A TO Z]" ), contains( node ) );
        assertThat( index.query( "name", "[a TO z]" ), isEmpty() );
        assertThat( index.query( "name", "Matt*" ), contains( node ) );
        assertThat( index.query( "name", "matt*" ), isEmpty() );
        assertThat( index.query( "name", "Persson" ), contains( node ) );
        assertThat( index.query( "name", "persson" ), isEmpty() );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:TestLuceneIndex.java

示例7: main

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
public static void main( String[] args )
{
    GraphDatabaseService db = new TestGraphDatabaseFactory().newEmbeddedDatabase( args[0] );
    try ( Transaction tx = db.beginTx() )
    {
        Index<Relationship> index = db.index().forRelationships( "myIndex" );
        Node node = db.createNode();
        Relationship relationship = db.createNode().createRelationshipTo( node,
                DynamicRelationshipType.withName( "KNOWS" ) );

        index.add( relationship, "key", "value" );
        tx.success();
    }

    db.shutdown();
    System.exit( 0 );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:18,代码来源:RecoveryTest.java

示例8: useStandardAnalyzer

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void useStandardAnalyzer() throws Exception
{
    Index<Node> index = nodeIndex( stringMap( "analyzer", MyStandardAnalyzer.class.getName() ) );
    Node node = graphDb.createNode();
    index.add( node, "name", "Mattias" );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:8,代码来源:TestLuceneIndex.java

示例9: 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();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:16,代码来源:TestIndexDeletion.java

示例10: makeSureYouGetLatestTxModificationsInQueryByDefault

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void makeSureYouGetLatestTxModificationsInQueryByDefault()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.FULLTEXT_CONFIG );
    Node node = graphDb.createNode();
    index.add( node, "key", "value" );
    assertThat( index.query( "key:value" ), contains( node ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:9,代码来源:TestLuceneIndex.java

示例11: testRemoveWithoutKeyValue

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void testRemoveWithoutKeyValue(
        EntityCreator<T> creator, Index<T> index ) throws Exception
{
    String key1 = "key1";
    String value1 = "value1";
    String key2 = "key2";
    String value2 = "value2";

    T entity1 = creator.create();
    index.add( entity1, key1, value1 );
    index.add( entity1, key2, value2 );
    T entity2 = creator.create();
    index.add( entity2, key1, value1 );
    index.add( entity2, key2, value2 );
    restartTx();

    assertContains( index.get( key1, value1 ), entity1, entity2 );
    assertContains( index.get( key2, value2 ), entity1, entity2 );
    index.remove( entity1 );
    assertContains( index.get( key1, value1 ), entity2 );
    assertContains( index.get( key2, value2 ), entity2 );
    index.add( entity1, key1, value1 );

    for ( int i = 0; i < 2; i++ )
    {
        assertContains( index.get( key1, value1 ), entity1, entity2 );
        assertContains( index.get( key2, value2 ), entity2 );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestLuceneIndex.java

示例12: testSimilarity

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testSimilarity()
{
    Index<Node> index = nodeIndex( MapUtil.stringMap( IndexManager.PROVIDER, "lucene",
            "type", "fulltext", "similarity",  DefaultSimilarity.class.getName() ) );
    Node node = graphDb.createNode();
    index.add( node, "key", "value" );
    restartTx();
    assertContains( index.get( "key", "value" ), node );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:11,代码来源:TestLuceneIndex.java

示例13: 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();
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestLuceneIndex.java

示例14: testRemoveWithoutKey

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void testRemoveWithoutKey(
        EntityCreator<T> creator, Index<T> index ) throws Exception
{
    String key1 = "key1";
    String key2 = "key2";
    String value = "value";

    T entity1 = creator.create();
    index.add( entity1, key1, value );
    index.add( entity1, key2, value );
    T entity2 = creator.create();
    index.add( entity2, key1, value );
    index.add( entity2, key2, value );
    restartTx();

    assertContains( index.get( key1, value ), entity1, entity2 );
    assertContains( index.get( key2, value ), entity1, entity2 );
    index.remove( entity1, key2 );
    assertContains( index.get( key1, value ), entity1, entity2 );
    assertContains( index.get( key2, value ), entity2 );
    index.add( entity1, key2, value );
    for ( int i = 0; i < 2; i++ )
    {
        assertContains( index.get( key1, value ), entity1, entity2 );
        assertContains( index.get( key2, value ), entity1, entity2 );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:30,代码来源:TestLuceneIndex.java

示例15: testRemoveWithoutKeyValueFulltext

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@SuppressWarnings( "unchecked" )
private <T extends PropertyContainer> void testRemoveWithoutKeyValueFulltext(
        EntityCreator<T> creator, Index<T> index ) throws Exception
{
    String value = "value";
    String key1 = "key1";
    String value1 = value + " one";
    String key2 = "key2";
    String value2 = value + " two";

    T entity1 = creator.create();
    index.add( entity1, key1, value1 );
    index.add( entity1, key2, value2 );
    T entity2 = creator.create();
    index.add( entity2, key1, value1 );
    index.add( entity2, key2, value2 );
    restartTx();

    assertContains( index.query( key1, value ), entity1, entity2 );
    assertContains( index.query( key2, value ), entity1, entity2 );
    index.remove( entity1 );
    assertContains( index.query( key1, value ), entity2 );
    assertContains( index.query( key2, value ), entity2 );
    index.add( entity1, key1, value1 );
    for ( int i = 0; i < 2; i++ )
    {
        assertContains( index.query( key1, value ), entity1, entity2 );
        assertContains( index.query( key2, value ), entity2 );
        restartTx();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:32,代码来源:TestLuceneIndex.java


注:本文中的org.neo4j.graphdb.index.Index.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。