Please comment on this use-case for accessing the Lucene API directly from the context of a Neo4j User Defined Procedure - neo4j

I would like to build an in-memory Lucene index from a collection of node properties and then search against that index.
These search transactions will be happening in parallel, I need to be able to construct a separate search index for each transaction. It seems like this would not be possible using native (manual) Neo4j indexes, since they are "global", hence the use of a memory-based search index, am I mistaken?

This is working great for our use case. A couple of notes:
Use MemoryIndex rather than RAMDirectory.
Be sure to specify "provided" in your dependencies for Lucene.
You can only use 5.5.0, which is what is used natively by Neo4j.

Related

Query tags/context labels of senses using JWKTL

I am working on a project where I need to deal with Wiktionary. For some entries, there are context labels/tags before its sense I want to query for, e.g. idiomatic, transitive like HERE. I am now trying to use JWKTL, to do the job. But it seems no api call supports the query.
Can anyone let me know how to get that information by JWKTL, or, is there any other tool can parse the Wiktionary dump .xml file while being able to access that labels/tags?
Thanks.
According to Dr. Christian. Meyer, there is currently no API on this.
I ended up with pattern matching in the original wiktionary .xml dump.

How could execute multiple cypher at a time in neo4j.

I want to execute multiple cypher queries at same time for the brower, how count i execute that. And i am using noe4j version for 2.2.5. My sample query was,
CREATE(n:Taxonomy{UUID:10001, name:"BOSH", classType:"Interface Type", version:"2.2",isDeleted:"0"});
CREATE(n:Taxonomy{UUID:10002, name:"Iaas", classType:"AWS", version:"0.0",isDeleted:"0"});
CREATE(n:Taxonomy{UUID:10003, name:"order lifecycle", classType:"draft order", version:"0.0",isDeleted:"0"});
CREATE(n:IaaSTemplate{UUID:20001, IaasName:"Iaas Template 1",isDeleted:"0"});
CREATE(n:TemplateFunction{UUID:30001, functionName:"bosh target",isDeleted:"0"});
CREATE(n:TemplateFunction{UUID:30002, functionName:"bosh login",isDeleted:"0"});
Batching multiple queries into one is not (yet) supported by the Browser.
However, the specific queries in your question can be easily combined into a single query by:
Removing the n identifier from all the nodes.
Within a single query, an identifier is associated with a specific instance of a node or relationship (ignoring the effect of WITH clauses). But, since you don't actually use the identifier, getting rid of it would allow all the CREATE clauses to co-exist in the same query.
Removing all semicolons (except the last one).
So, this should work:
CREATE(:Taxonomy{UUID:10001, name:"BOSH", classType:"Interface Type", version:"2.2",isDeleted:"0"})
CREATE(:Taxonomy{UUID:10002, name:"Iaas", classType:"AWS", version:"0.0",isDeleted:"0"})
CREATE(:Taxonomy{UUID:10003, name:"order lifecycle", classType:"draft order", version:"0.0",isDeleted:"0"})
CREATE(:IaaSTemplate{UUID:20001, IaasName:"Iaas Template 1",isDeleted:"0"})
CREATE(:TemplateFunction{UUID:30001, functionName:"bosh target",isDeleted:"0"})
CREATE(:TemplateFunction{UUID:30002, functionName:"bosh login",isDeleted:"0"});
Unfortunately Neo4j Browser doesn't support that yet, it's on the long list of things.
You can use the bin/neo4j-shell that connects to a running browser.
Or a project like cycli which is a colorful, auto-complete shell for Neo4j that talks to the http interface and supports auth etc.

Neo4j full text index

I am using node.js to connect to the neo4j database. Whenever I have to set an index for a node, I do it manually by going to the neo4j browser (localhost:7474).
CREATE INDEX ON :user(username)
First of all to be clear, this is an automatic index? Any changes or additions to :user are automatically maintained? Let me know if I am wrong.
If so, how does full text index work on neo4j? Is it the same process and neo manages automatically? For example does the following create full text index? Or we need to do something else?
CREATE INDEX ON :user(aboutme)
I built my own nodejs adapter to connect to neo4j, and so I only have access to cypher queries at the moment. To create an index I only have access to cypher or the browser (7474). So what is the proper way to create automatic fulltext index, preferably from the browser itself? And how do I access it using the cypher (or do I have to access it? does neo automatically figure out what index to use?). Online documentation and tutorials are a bit complicated for beginners :/ .
(I want to be able to do text search on the :user(aboutme) property)
If you want a full text index (where you can use the index to match on parts of the string and not the full, exact string), that isn't currently supported by the new cypher automatic indexes (like CREATE INDEX ON :user(username)). To do that you need to use what are called the legacy indexes. These use lucene under the covers and are much more powerful, but I believe they will eventually go away once that same functionality is supported with the new indexes.
Personally for full-text search I prefer using something like elasticsearch as it is easier to set up and use.

How do I create a spacial index in neo4j using only cypher?

I want to play with neo4j and spacial indexes. I can't find any documentation that demonstrates how to do this through cypher, only through the REST API.
Is it possibly to create spacial indexes through Cypher, say in the neo4j web console?
There is currently no way to create a spatial index using Cypher. You can either use java API or a REST call, see docs at http://neo4j-contrib.github.io/spatial/#rest-api-create-a-spatial-index for details. Since Neo4j browser allows to send HTTP POST you can type there:
:POST /db/data/index/node {"name":"geom", "config":
{"provider":"spatial", "geometry_type":"point", "lat":"lat", "lon":"lon"}
}
Alternatively you can use the index command within neo4j-shell.
Update for Neo4j 3.0
Neo4j Spatial for 3.0 provides stored procedures to manage the spatial index - and therefore everything can be done through cypher. See https://github.com/neo4j-contrib/spatial/blob/master/src/main/java/org/neo4j/gis/spatial/procedures/SpatialProcedures.java.
Note: this version is not yet released, so you have to build from source yourself.

Meteor publish-with-relations VS collection-helpers for joins?

What's the best way to do joins in Meteor/mongo? Use one of these packages, or something else:
publish-with-relations
https://github.com/erundook/meteor-publish-with-relations/blob/master/publish_with_relations.coffee
collection-helpers
https://github.com/dburles/meteor-collection-helpers
I'm very familiar with PWR, but collection-helpers is new to me. It looks like the two are complimentary.
PWR solves the somewhat complex problem of publishing documents to the client via a reactive join based on arbitrarily complex relationships. See this question for more details.
collection-helpers appears to be a set of convenience functions added to the client to be used when traversing collection relationships inside of a template (given that the required documents have already been published). For example, if you have books and authors in separate (but related) collections, you can immediately get myBook.author.fullName inside of a template without having to type out the extra find for the author.
currently the top popular solution in atmosphere seems to be publish-composite https://atmospherejs.com/reywood/publish-composite

Resources