本文整理汇总了Java中org.neo4j.graphdb.index.IndexManager.forNodes方法的典型用法代码示例。如果您正苦于以下问题:Java IndexManager.forNodes方法的具体用法?Java IndexManager.forNodes怎么用?Java IndexManager.forNodes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.neo4j.graphdb.index.IndexManager
的用法示例。
在下文中一共展示了IndexManager.forNodes方法的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: 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();
}
示例8: 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;
}
示例9: 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;
}
示例10: 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);
}
示例11: 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);
}
示例12: 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());
}
}
示例13: deleteNodeIndex
import org.neo4j.graphdb.index.IndexManager; //导入方法依赖的package包/类
@Override
public void deleteNodeIndex(String name, ParcelableError err) throws RemoteException {
try {
checkCallerHasWritePermission();
resumeTrx();
try {
IndexManager index = mDb.index();
index.forNodes(name); // this will create the index
} finally {
suspendCurrentTrx("deleteNodeIndex");
}
} catch (Exception e) {
Log.e(TAG, "Failed to delete node index '" + name + "'", e);
err.setError(Errors.TRANSACTION, e.getMessage());
}
}
示例14: getPosTagByLabel
import org.neo4j.graphdb.index.IndexManager; //导入方法依赖的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();
}
示例15: getPosHeadByLabel
import org.neo4j.graphdb.index.IndexManager; //导入方法依赖的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();
}