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


Java Index.get方法代码示例

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


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

示例1: getTypedNodeTokenCount

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
public Long getTypedNodeTokenCount(String type, String pattern, Boolean sensitive) {
	Long frequency = (long) 0;

	try ( Transaction ignored = database.beginTx(); ) {
		IndexManager index = database.index();
		Index<Node> nodeIndex = index.forNodes(type);
		for (Node match : nodeIndex.get("label", pattern)) {
			if (!sensitive || ((String) match.getProperty("label")).equals(pattern)) {
				Object count = match.getProperty("token_count");
				if (count instanceof Integer)
					frequency = frequency + new Long((Integer) count);
				else if (count instanceof Long)
					frequency = frequency + (Long) count;
			}
		}
	}
	
	return frequency;
}
 
开发者ID:Taalmonsters,项目名称:WhiteLab2.0-Neo4J-Plugin,代码行数:20,代码来源:CypherExecutor.java

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

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

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

示例5: getPosTagByLabel

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@GET
@Path("/tags/{label}")
public Response getPosTagByLabel(@PathParam("label") final String label)
{
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction ignored = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Node> postags = index.forNodes("PosTag");
				IndexHits<Node> hits = postags.get( "label", label );
				Node postag = hits.getSingle();
				jg.writeStartObject();
				for (String field : postag.getPropertyKeys()) {
					Object value = postag.getProperty(field);
					if (field.contains("_count") && value instanceof Integer)
						jg.writeNumberField(field, (Integer) value);
					else if (field.contains("_count") && value instanceof Long)
						jg.writeNumberField(field, (Long) value);
					else
						jg.writeStringField(field, (String) postag.getProperty(field));
				}
				jg.writeEndObject();
				jg.flush();
				jg.close();
			}
		}
	};

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

示例6: getPosHeadByLabel

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@GET
@Path("/heads/{label}")
public Response getPosHeadByLabel(@PathParam("label") final String label)
{
	StreamingOutput stream = new StreamingOutput()
	{
		@Override
		public void write( OutputStream os ) throws IOException, WebApplicationException
		{
			try ( Transaction ignored = database.beginTx() ) {
				JsonGenerator jg = objectMapper.getFactory().createGenerator(os, JsonEncoding.UTF8);
				IndexManager index = database.index();
				Index<Node> postags = index.forNodes("PosHead");
				IndexHits<Node> hits = postags.get( "label", label );
				Node poshead = hits.getSingle();
				jg.writeStartObject();
				for (String field : poshead.getPropertyKeys()) {
					Object value = poshead.getProperty(field);
					if (field.contains("_count") && value instanceof Integer)
						jg.writeNumberField(field, (Integer) value);
					else if (field.contains("_count") && value instanceof Long)
						jg.writeNumberField(field, (Long) value);
					else
						jg.writeStringField(field, (String) poshead.getProperty(field));
				}
				jg.writeEndObject();
				jg.flush();
				jg.close();
			}
		}
	};

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

示例7: getMetadataGroupKeyValueDocuments

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
protected Response getMetadataGroupKeyValueDocuments(final String group, final String key, 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<Relationship> metadataValues = index.forRelationships("HAS_METADATUM");
				List<String> documentsSeen = new ArrayList<String>();
				jg.writeStartArray();
				
				System.out.println("VALUE: "+value);
				for (Relationship hasMetadatum : metadataValues.get("value", value)) {
					Node metadatum = hasMetadatum.getEndNode();
					String mGroup = (String) metadatum.getProperty("group");
					String mKey = (String) metadatum.getProperty("key");
					if (mGroup.equals(group) && mKey.equals(key)) {
						Node document = hasMetadatum.getStartNode();
						String xmlid = (String) document.getProperty("xmlid");
						if (!documentsSeen.contains(xmlid)) {
							jg.writeString(xmlid);
							documentsSeen.add(xmlid);
						}
					}
				}
				
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

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

示例8: doGetForNodes

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
@Test
public void doGetForNodes()
{
    Index<Node> actors = graphDb.index().forNodes( "actors" );

    // START SNIPPET: getSingleNode
    IndexHits<Node> hits = actors.get( "name", "Keanu Reeves" );
    Node reeves = hits.getSingle();
    // END SNIPPET: getSingleNode

    assertEquals( "Keanu Reeves", reeves.getProperty( "name" ) );
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:13,代码来源:ImdbDocTest.java

示例9: queryIndex

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
private IndexHits<Node> queryIndex( Index<Node> index )
{
    GraphDatabaseService graphDatabaseService = dbRule.getGraphDatabaseService();
    try ( Transaction transaction = graphDatabaseService.beginTx() )
    {
        return index.get( "foo", 42 );
    }
}
 
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:9,代码来源:MandatoryTransactionsForIndexHitsFacadeTests.java

示例10: getMetadataGroupKeyValueDocumentsWithCounts

import org.neo4j.graphdb.index.Index; //导入方法依赖的package包/类
protected Response getMetadataGroupKeyValueDocumentsWithCounts(final String group, final String key, 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<Relationship> metadataValues = index.forRelationships("HAS_METADATUM");
				List<String> documentsSeen = new ArrayList<String>();
				jg.writeStartArray();
				
				System.out.println("VALUE: "+value);
				for (Relationship hasMetadatum : metadataValues.get("value", value)) {
					Node metadatum = hasMetadatum.getEndNode();
					String mGroup = (String) metadatum.getProperty("group");
					String mKey = (String) metadatum.getProperty("key");
					if (mGroup.equals(group) && mKey.equals(key)) {
						Node document = hasMetadatum.getStartNode();
						String xmlid = (String) document.getProperty("xmlid");
						if (!documentsSeen.contains(xmlid)) {
							jg.writeStartObject();
							jg.writeStringField("xmlid", xmlid);
							Object tokenCount = document.getProperty("token_count");
							if (tokenCount instanceof Long)
								jg.writeNumberField("token_count", (Long) tokenCount);
							else if (tokenCount instanceof Integer)
								jg.writeNumberField("token_count", (Integer) tokenCount);
							jg.writeEndObject();
							documentsSeen.add(xmlid);
						}
					}
				}
				
				jg.writeEndArray();
				jg.flush();
				tx.success();
			}
		}
	};

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

示例11: call

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


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