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


Java Index.query方法代码示例

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


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

示例1: getMetadataLabel

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
protected Response getMetadataLabel(final String label) {
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction tx = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Node> metadata = index.forNodes("Metadatum");
				jg.writeStartArray();
				for ( Node metadatum : metadata.query( "label:"+label ) ) {
					executor.writeField(metadatum, jg);
				}
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

	return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:24,代码来源:MetadatumSearcher.java

示例2: updateMetadataLabel

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
protected Response updateMetadataLabel(final String label, final String property, final String value) {
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction tx = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Node> metadata = index.forNodes("Metadatum");
				for ( Node metadatum : metadata.query( "label:"+label ) ) {
					if (property.equals("explorable") || property.equals("searchable"))
						metadatum.setProperty(property, Boolean.valueOf(value));
					else
						metadatum.setProperty(property, value);
				}
				jg.writeString("Updated "+label);
				jg.flush();
				tx.success();
			}
		}
	};

	return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:26,代码来源:MetadatumSearcher.java

示例3: getMetadataGroupKey

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
protected Response getMetadataGroupKey(final String group, final String key) {
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction tx = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Node> metadata = index.forNodes("Metadatum");
				jg.writeStartArray();
				for ( Node metadatum : metadata.query( "group:"+group+" AND key:"+key ) ) {
					executor.writeField(metadatum, jg);
				}
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

	return Response.ok().entity( stream ).type( MediaType.APPLICATION_JSON ).build();
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:24,代码来源:MetadatumSearcher.java

示例4: 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

示例5: doSomeQueries

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void doSomeQueries()
{
    Index<Node> persons = graphDb.index().forNodes( "persons" );
    
    // START SNIPPET: query
    for ( Node person : persons.query( "name", "*e*" ) )
    {
        // It will get Morpheus and Neo
    }
    Node neo = persons.query( "name:*e* AND title:\"The One\"" ).getSingle();
    // END SNIPPET: query

    assertNotNull( neo );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:16,代码来源:LuceneIndexSiteExamples.java

示例6: indexHitsFromQueryingRemovedDoesNotReturnNegativeCount

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void indexHitsFromQueryingRemovedDoesNotReturnNegativeCount()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
    Node theNode = graphDb.createNode();
    index.remove( theNode );
    IndexHits<Node> hits = index.query( "someRandomKey", theNode.getId() );
    assertTrue( hits.size() >= 0 );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:10,代码来源:TestLuceneIndex.java

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

示例8: testNumericValueArrays

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testNumericValueArrays()
{
    Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );

    Node node1 = graphDb.createNode();
    index.add( node1, "number", new ValueContext[]{ numeric( 45 ), numeric( 98 ) } );
    Node node2 = graphDb.createNode();
    index.add( node2, "number", new ValueContext[]{ numeric( 47 ), numeric( 100 ) } );


    IndexHits<Node> indexResult1 = index.query( "number", newIntRange( "number", 47, 98, true, true ) );
    assertThat( indexResult1, contains( node1, node2 ) );
    assertThat( indexResult1.size(), is( 2 ));

    IndexHits<Node> indexResult2 = index.query( "number", newIntRange( "number", 44, 46, true, true ) );
    assertThat( indexResult2, contains( node1 ) );
    assertThat( indexResult2.size(), is( 1 ) );

    IndexHits<Node> indexResult3 = index.query( "number", newIntRange( "number", 99, 101, true, true ) );
    assertThat( indexResult3, contains( node2 ) );
    assertThat( indexResult3.size(), is( 1 ) );

    IndexHits<Node> indexResult4 = index.query( "number", newIntRange( "number", 47, 98, false, false ) );
    assertThat( indexResult4, isEmpty() );

    IndexHits<Node> indexResult5 = index.query( "number", numericRange( "number", null, 98, true, true ) );
    assertContains( indexResult5, node1, node2 );

    IndexHits<Node> indexResult6 = index.query( "number", numericRange( "number", 47, null, true, true ) );
    assertContains( indexResult6, node1, node2 );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:33,代码来源:TestLuceneIndex.java

示例9: shouldThrowIllegalStateForActionsAfterDeletedOnIndex4

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test( expected = IllegalStateException.class )
public void shouldThrowIllegalStateForActionsAfterDeletedOnIndex4()
{
    restartTx();
    index.delete();
    Index<Node> newIndex = graphDb.index().forNodes( INDEX_NAME );
    newIndex.query( key, "own" );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:9,代码来源:TestIndexDeletion.java

示例10: testNumericValueArrays

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void testNumericValueArrays()
{
    BatchInserterIndexProvider provider = new LuceneBatchInserterIndexProviderNewImpl( inserter );
    BatchInserterIndex batchIndex = provider.nodeIndex( "mine", EXACT_CONFIG );

    long nodeId1 = inserter.createNode( null );
    batchIndex.add( nodeId1, map( "number", new ValueContext[]{ numeric( 45 ), numeric( 98 ) } ) );
    long nodeId2 = inserter.createNode( null );
    batchIndex.add( nodeId2, map( "number", new ValueContext[]{numeric( 47 ), numeric( 100 )} ) );
    batchIndex.flush();

    IndexHits<Long> batchIndexResult1 = batchIndex.query( "number", newIntRange( "number", 47, 98, true, true ) );
    assertThat( batchIndexResult1, contains(nodeId1, nodeId2));
    assertThat( batchIndexResult1.size(), is( 2 ));

    IndexHits<Long> batchIndexResult2 = batchIndex.query( "number", newIntRange( "number", 44, 46, true, true ) );
    assertThat( batchIndexResult2, contains(nodeId1));
    assertThat( batchIndexResult2.size(), is( 1 ) );

    IndexHits<Long> batchIndexResult3 = batchIndex.query( "number", newIntRange( "number", 99, 101, true, true ) );
    assertThat( batchIndexResult3, contains( nodeId2 ) );
    assertThat( batchIndexResult3.size(), is( 1 ) );

    IndexHits<Long> batchIndexResult4 = batchIndex.query( "number", newIntRange( "number", 47, 98, false, false ) );
    assertThat( batchIndexResult4, isEmpty() );

    provider.shutdown();

    switchToGraphDatabaseService();
    try ( Transaction transaction = db.beginTx() )
    {
        Node node1 = db.getNodeById( nodeId1 );
        Node node2 = db.getNodeById( nodeId2 );
        Index<Node> index = db.index().forNodes( "mine" );

        IndexHits<Node> indexResult1 = index.query( "number", newIntRange( "number", 47, 98, true, true ) );
        assertThat(indexResult1, contains(node1, node2));
        assertThat( indexResult1.size(), is( 2 ));

        IndexHits<Node> indexResult2 = index.query( "number", newIntRange( "number", 44, 46, true, true ) );
        assertThat(indexResult2, contains(node1));
        assertThat( indexResult2.size(), is( 1 ) );

        IndexHits<Node> indexResult3 = index.query( "number", newIntRange( "number", 99, 101, true, true ) );
        assertThat( indexResult3, contains( node2 ) );
        assertThat( indexResult3.size(), is( 1 ) );

        IndexHits<Node> indexResult4 = index.query( "number", newIntRange( "number", 47, 98, false, false ) );
        assertThat( indexResult4, isEmpty() );
        transaction.success();
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:54,代码来源:TestLuceneBatchInsert.java

示例11: testInsertionSpeed

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
private <T extends PropertyContainer> void testInsertionSpeed(
        Index<T> index,
        EntityCreator<T> creator )
{
    long t = currentTimeMillis();
    int max = 500000;
    for ( int i = 0; i < max; i++ )
    {
        T entity = creator.create();
        if ( i % 5000 == 5 )
        {
            index.query( new TermQuery( new Term( "name", "The name " + i ) ) );
        }
        lastOrNull( (Iterable<T>) index.query( new QueryContext( new TermQuery( new Term( "name", "The name " + i ) ) ).tradeCorrectnessForSpeed() ) );
        lastOrNull( (Iterable<T>) index.get( "name", "The name " + i ) );
        index.add( entity, "name", "The name " + i );
        index.add( entity, "title", "Some title " + i );
        index.add( entity, "something", i + "Nothing" );
        index.add( entity, "else", i + "kdfjkdjf" + i );
        if ( i % 30000 == 0 )
        {
            restartTx();
            System.out.println( i );
        }
    }
    finishTx( true );
    out.println( "insert:" + ( currentTimeMillis() - t ) );

    t = currentTimeMillis();
    int count = 2000000;
    int resultCount = 0;
    for ( int i = 0; i < count; i++ )
    {
        resultCount += count( (Iterator<T>) index.get( "name", "The name " + i%max ) );
    }
    out.println( "get(" + resultCount + "):" + (double)( currentTimeMillis() - t ) / (double)count );

    t = currentTimeMillis();
    resultCount = 0;
    for ( int i = 0; i < count; i++ )
    {
        resultCount += count( (Iterator<T>) index.get( "something", i%max + "Nothing" ) );
    }
    out.println( "get(" + resultCount + "):" + (double)( currentTimeMillis() - t ) / (double)count );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:46,代码来源:PerformanceAndSanityIT.java

示例12: call

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Override
public void call( Index<Node> self )
{
    self.query( "foo", "bar" );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:6,代码来源:NodeIndexFacadeMethods.java


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