本文整理汇总了Java中org.neo4j.graphdb.index.Index类的典型用法代码示例。如果您正苦于以下问题:Java Index类的具体用法?Java Index怎么用?Java Index使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Index类属于org.neo4j.graphdb.index包,在下文中一共展示了Index类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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: 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
示例3: 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
示例4: 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
示例5: 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();
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:17,代码来源:ImdbDocTest.java
示例6: fulltext
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Test
public void fulltext()
{
// START SNIPPET: fulltext
IndexManager index = graphDb.index();
Index<Node> fulltextMovies = index.forNodes( "movies-fulltext",
MapUtil.stringMap( IndexManager.PROVIDER, "lucene", "type", "fulltext" ) );
// END SNIPPET: fulltext
Index<Node> movies = index.forNodes( "movies" );
Node theMatrix = movies.get( "title", "The Matrix" ).getSingle();
Node theMatrixReloaded = movies.get( "title", "The Matrix Reloaded" ).getSingle();
// START SNIPPET: fulltext
fulltextMovies.add( theMatrix, "title", "The Matrix" );
fulltextMovies.add( theMatrixReloaded, "title", "The Matrix Reloaded" );
// search in the fulltext index
Node found = fulltextMovies.query( "title", "reloAdEd" ).getSingle();
// END SNIPPET: fulltext
assertEquals( theMatrixReloaded, found );
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:ImdbDocTest.java
示例7: 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
示例8: 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();
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:27,代码来源:TestLuceneIndex.java
示例9: 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();
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:27,代码来源:TestLuceneIndex.java
示例10: 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();
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:23,代码来源:TestLuceneIndex.java
示例11: testIndexNumberAsString
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Test
public void testIndexNumberAsString()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
Node node1 = graphDb.createNode();
index.add( node1, "key", 10 );
for ( int i = 0; i < 2; i++ )
{
assertEquals( node1, index.get( "key", 10 ).getSingle() );
assertEquals( node1, index.get( "key", "10" ).getSingle() );
assertEquals( node1, index.query( "key", 10 ).getSingle() );
assertEquals( node1, index.query( "key", "10" ).getSingle() );
restartTx();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:17,代码来源:TestLuceneIndex.java
示例12: makeSureFulltextConfigIsCaseInsensitiveByDefault
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Test
public void makeSureFulltextConfigIsCaseInsensitiveByDefault()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.FULLTEXT_CONFIG );
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]" ), contains( node ) );
assertThat( index.query( "name", "Mattias" ), contains( node ) );
assertThat( index.query( "name", "mattias" ), contains( node ) );
assertThat( index.query( "name", "Matt*" ), contains( node ) );
assertThat( index.query( "name", "matt*" ), contains( node ) );
restartTx();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:20,代码来源:TestLuceneIndex.java
示例13: 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
示例14: 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
示例15: 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
示例16: 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
示例17: 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
示例18: updateIndex
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Test
public void updateIndex() throws Exception {
String TEXT = "text";
String NUMERIC = "numeric";
String TEXT_1 = "text_1";
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
Node n = graphDb.createNode();
index.add(n, NUMERIC, new ValueContext(5).indexNumeric());
index.add(n, TEXT, "text");
index.add(n, TEXT_1, "text");
commitTx();
beginTx();
assertNotNull( index.query( QueryContext.numericRange( NUMERIC, 5, 5, true, true ) ).getSingle() );
assertNotNull( index.get( TEXT_1, "text" ).getSingle() );
index.remove( n, TEXT, "text" );
index.add( n, TEXT, "text 1" );
commitTx();
beginTx();
assertNotNull( index.get(TEXT_1, "text").getSingle() );
assertNotNull( index.query(QueryContext.numericRange(NUMERIC, 5, 5, true, true)).getSingle() );
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:25,代码来源:TestLuceneIndex.java
示例19: shouldNotBeAbleToIndexNodeThatIsNotCommitted
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Ignore( "an issue that should be fixed at some point" )
@Test( expected = NotFoundException.class )
public void shouldNotBeAbleToIndexNodeThatIsNotCommitted() throws Exception
{
Index<Node> index = nodeIndex(
LuceneIndexImplementation.EXACT_CONFIG );
Node node = graphDb.createNode();
String key = "noob";
String value = "Johan";
WorkThread thread = new WorkThread( "other thread", index, graphDb, node );
thread.beginTransaction();
try
{
thread.add( node, key, value );
}
finally
{
thread.rollback();
}
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:22,代码来源:TestLuceneIndex.java
示例20: putIfAbsentSingleThreaded
import org.neo4j.graphdb.index.Index; //导入依赖的package包/类
@Test
public void putIfAbsentSingleThreaded()
{
Index<Node> index = nodeIndex( LuceneIndexImplementation.EXACT_CONFIG );
Node node = graphDb.createNode();
String key = "name";
String value = "Mattias";
String value2 = "Persson";
assertNull( index.putIfAbsent( node, key, value ) );
assertEquals( node, index.get( key, value ).getSingle() );
assertNotNull( index.putIfAbsent( node, key, value ) );
assertNull( index.putIfAbsent( node, key, value2 ) );
assertNotNull( index.putIfAbsent( node, key, value2 ) );
restartTx();
assertNotNull( index.putIfAbsent( node, key, value ) );
assertNotNull( index.putIfAbsent( node, key, value2 ) );
assertEquals( node, index.get( key, value ).getSingle() );
}
开发者ID:neo4j-contrib,项目名称:neo4j-lucene5-index,代码行数:19,代码来源:TestLuceneIndex.java
注:本文中的org.neo4j.graphdb.index.Index类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论