本文整理汇总了Java中org.neo4j.graphdb.index.IndexManager类的典型用法代码示例。如果您正苦于以下问题:Java IndexManager类的具体用法?Java IndexManager怎么用?Java IndexManager使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
IndexManager类属于org.neo4j.graphdb.index包,在下文中一共展示了IndexManager类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getTypedNodeTokenCount
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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;
}
示例2: getMetadataLabel
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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();
}
示例3: updateMetadataLabel
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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();
}
示例4: getMetadataGroupKey
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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();
}
示例5: deleteIndex
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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();
}
示例6: fulltext
import org.neo4j.graphdb.index.IndexManager; //导入依赖的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 );
}
示例7: testCanIndexRelationships
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
@Test
public void testCanIndexRelationships()
{
BatchInserterIndexProvider indexProvider = new LuceneBatchInserterIndexProviderNewImpl( inserter );
BatchInserterIndex edgesIndex = indexProvider.relationshipIndex(
"edgeIndex", stringMap( IndexManager.PROVIDER, "lucene", "type", "exact" ) );
long nodeId1 = inserter.createNode( map( "ID", "1" ) );
long nodeId2 = inserter.createNode( map( "ID", "2" ) );
long relationshipId = inserter.createRelationship( nodeId1, nodeId2,
EdgeType.KNOWS, null );
edgesIndex.add( relationshipId, map( "EDGE_TYPE", EdgeType.KNOWS.name() ) );
edgesIndex.flush();
assertEquals(
String.format( "Should return relationship id" ),
new Long( relationshipId ),
edgesIndex.query( "EDGE_TYPE", EdgeType.KNOWS.name() ).getSingle() );
indexProvider.shutdown();
}
示例8: Neo4JEdgeIndex
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
public Neo4JEdgeIndex(String name, Neo4JDatabase neo4jDatabase) {
graph = neo4jDatabase;
this.name = name;
if (neo4jDatabase.getGraph() != null)
index = neo4jDatabase.getIndexer().forRelationships(
name,
MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
"exact"));
else
batchIndex = neo4jDatabase.getBatchIndexer().relationshipIndex(
name,
MapUtil.stringMap(IndexManager.PROVIDER, "lucene", "type",
"exact"));
}
示例9: WikiNerGraphConnector
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
private WikiNerGraphConnector(String dbDir) {
graphDb = new GraphDatabaseFactory().newEmbeddedDatabase(dbDir);
IndexDefinition indexDefinition;
Schema schema;
Transaction tx = graphDb.beginTx();
schema = graphDb.schema();
IndexManager index = graphDb.index();
entities = index.forNodes(entityLabel.name());
cities = index.forNodes(cityLabel.name());
try{
indexDefinition = schema.indexFor( entityLabel ).on( "nameType" ).create();
}catch(Exception e){
}
tx.success();
tx.close();
}
示例10: getOrCreateUserNode
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
public static Node getOrCreateUserNode(final GraphDatabaseService graphDb,
final String userID) {
IndexManager index = graphDb.index();
Index<Node> usersIndex = index.forNodes("users");
Node node = usersIndex.get("node_id", userID).getSingle();
if (node == null) {
node = graphDb.createNode(DynamicLabel.label("User"));
node.setProperty("node_id", userID);
usersIndex.add(node, "node_id", userID);
}
return node;
}
示例11: getOrCreateItemNode
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
public static Node getOrCreateItemNode(final GraphDatabaseService graphDb,
final String itemID) {
IndexManager index = graphDb.index();
Index<Node> usersIndex = index.forNodes("items");
Node node = usersIndex.get("node_id", itemID).getSingle();
if (node == null) {
node = graphDb.createNode(DynamicLabel.label("Item"));
node.setProperty("node_id", itemID);
usersIndex.add(node, "node_id", itemID);
}
return node;
}
示例12: addItem
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
@Override
public void addItem(int itemId) {
Node node = getNodeFromIndex(id);
int freq = 1;
//first check if the item has already been added
String itemAsStr = ITEM_ID_PREFIX + Integer.toString(itemId);
if(node.hasProperty(itemAsStr)){
Integer prevFreq = (Integer) node.getProperty(itemAsStr);
freq = prevFreq +1;
}
else{ //add to index only once
//add to lucene index
IndexManager IM = Utilities.recordDB.index();
Index<Node> itemIdx = IM.forNodes(ITEM_INDEX_NAME);
itemIdx.add(node, itemAsStr, "1");
}
node.setProperty(itemAsStr, freq);
}
示例13: addItem
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
public void addItem(int itemId) {
Node node = getNodeFromIndex(id);
int freq = 1;
//first check if the item has already been added
String itemAsStr = ITEM_ID_PREFIX + Integer.toString(itemId);
if(node.hasProperty(itemAsStr)){
Integer prevFreq = (Integer) node.getProperty(itemAsStr);
freq = prevFreq +1;
}
else{ //add to index only once
//add to lucene index
IndexManager IM = Utilities.recordDB.index();
Index<Node> itemIdx = IM.forNodes(ITEM_INDEX_NAME);
itemIdx.add(node, itemAsStr, "1");
}
node.setProperty(itemAsStr, freq);
}
示例14: createNodeIndex
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
@Override
public void createNodeIndex(String name, ParcelableError err) throws RemoteException {
try {
checkCallerHasWritePermission();
resumeTrx();
try {
IndexManager index = mDb.index();
index.forNodes(name); // this will create the index
} finally {
suspendCurrentTrx("createNodeIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to create/access node index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
}
}
示例15: nodeIndexExists
import org.neo4j.graphdb.index.IndexManager; //导入依赖的package包/类
@Override
public boolean nodeIndexExists(String name, ParcelableError err) throws RemoteException {
try {
resumeTrxIfExists();
try {
IndexManager index = mDb.index();
return index.existsForNodes(name);
} finally {
suspendCurrentTrx("nodeIndexExists");
}
} catch (Exception e) {
Log.e(TAG, "Failed to determine if node index '" + name + "' exists", e);
err.setError(Errors.TRANSACTION, e.getMessage());
return false; // dummy return value
}
}