How could execute multiple cypher at a time in neo4j. - 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.

Related

How to get proper results for these queries?

Need to execute and return 1st order detail alone for each order. Below doesn't work
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?$expand=Orders($expand=Order_Details;$top=1)
Need to filter records based on order id. Below doesn't work and throws "Term 'Orders($expand=Order_Details)$filter=OrderID eq '10643'' is not valid in a $select or $expand expression"
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?$expand=Orders($expand=Order_Details)$filter=OrderID eq '10643'
Invalid but returned results
https://services.odata.org/Experimental/Northwind/Northwind.svc/Regions?expand=Order_Details
https://services.odata.org/Experimental/Northwind/Northwind.svc/Regions?expand=Territories
Not Returning Childrens
https://services.odata.org/Experimental/Northwind/Northwind.svc/Products?&expand=Suppliers
https://services.odata.org/Experimental/Northwind/Northwind.svc/Regions?&expand=Territories
https://services.odata.org/Experimental/Northwind is no longer 'Best Practise'
It's a bold statement, but this question proves that many advanced query features have not been fully or properly implemented in the published service.
While many developers may use it to practise OData query concepts, given that the OData implementation is largely up to the developers and the version of the packages they use, it is probably a of more commercial value if you query against a live or a dev implementation of the actual service that you want to query.
The following is an analysis of OPs queries and how to achieve the desired response according the the OData-V4 specification and verified against a deployed API that utilises the following NuGet packages:
Microsoft.AspNet.OData v7.3.0
Microsoft.OData.Core v7.6.2
The actual API that I used for testing is proprietary and cannot be published here.
According to the spec, you have to move the $top specifier to the Order_Details expansion.
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?
$expand=Orders($expand=Order_Details($top=1))
However:
https://services.odata.org/Experimental/Northwind does not correctly implement $top query option within expansion as defined in 5.1.3 System Query Option $expand
Query options can be applied to an expanded navigation property by appending a semicolon-separated list of query options, enclosed in parentheses, to the navigation property name. Allowed system query options are $filter, $select, $orderby, $skip, $top, $count, $search, and $expand.
$top is however supported in the ODataLib v7+ (.Net) implementation of OData v4. So the syntax is correct, but you should check with your API developers for their opinion if your queries with this syntax do not work.
NOTE: When using $top you should also use $orderbyto ensure that the query results are reliable and reproducable:
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?
$expand=Orders($expand=Order_Details($orderby=ProductID;$top=1))
To apply multiple query options within an expansion, you must separate then with a semi-colon: ;. However that alone will not prevent other customer records from being returned, so you must also add a root level filter as well, which is complicated by the fact that Orders is a collection. We can use the any function to only return customers that have an order with the specified Id:
Also note that OrderID is numeric, so do not wrap comparison values in quotes
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?
$expand=Orders($expand=Order_Details;$filter=OrderID eq 10643)
&$filter=Orders/any(o:o/OrderID eq 10643)
this can be further simplified using parameter alias:
https://services.odata.org/Experimental/Northwind/Northwind.svc/Customers?
$expand=Orders($expand=Order_Details;$filter=OrderID eq #orderId)
&$filter=Orders/any(o:o/OrderID eq #orderId)
&#orderId='10643'
However:
https://services.odata.org/Experimental/Northwind does not correctly implement parameter aliases so you cannot verify the alias syntax against this service.
Also note
that experimental service is not correctly applying the filter to either the root elements or the navigation collection, the syntax shown here does however work against the .Net ODataLib implementations of OData v4.
The reason that your $expand is not working is that you have left off the $ from the parameter name. The OData query interpreter only identifies query options are parameters that start with $.
Eitherway, according to the https://services.odata.org/Experimental/Northwind/Northwind.svc/$metadata#Regions, there is no Order_Details navigation property to $expand on:
<EntitySet Name="Regions" EntityType="NorthwindModel.Region">
<NavigationPropertyBinding Path="Territories" Target="Territories" />
</EntitySet>
So when you try again with the correct syntax:
https://services.odata.org/Experimental/Northwind/Northwind.svc/Regions?$expand=Order_Details
you get the expected message:
Could not find a property named 'OrderID' on type 'NorthwindModel.Region'
The second attempt will work if you put the correct $ in there for the $expand query option:
https://services.odata.org/Experimental/Northwind/Northwind.svc/Regions?$expand=Territories
The OData query parser only looks for the expected query options with the $ prefix, this allows your API logic to still process other non-OData parameters as you see fit to do so. The other parameters therefor are still HTTP Url compliant parameters, the implementation at odata.org doesn't know what to do with them and they are simply ignored.
This is just another variation on the same issue with 3, the $ is missing. (I suspect that this URL was meant to be in 3: https://services.odata.org/Experimental/Northwind/Northwind.svc/Products?$expand=Suppliers)
So while https://services.odata.org/Experimental/Northwind is not 100% reliable, neither are the .Net ODataLib, SAP or MS Dynamics implementations. The spec is evolving and there are many query techniques that are not fully implemented in probably any providers at this stage.
Simply be mindful of this fact and when you run into issues using an API, the first point of contact should be the developers or the community that are supporting that particular API, it will be up to the developers what techniques and packages they use and at the end of the day to what extent they support the protocol as it is specified.

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

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.

How do you determin a parent/child relationship in Intersystems Cache?

I'm having trouble using implicit joins or Arrow joins "->". It's on an Intersystems Cache database. This is my code that isn't working
SELECT qcpr_arf_OC.AssessmentCategoryDataElement->AssessmentCategoryID
FROM qcpr_arf_OC.AssessmentCategory
I've read through Intersystems Implicit join page http://docs.intersystems.com/ens20102/csp/docbook/DocBook.UI.Page.cls?KEY=GSQL_specialfeatures
And I tried to alter this one to work as it's also a for the QCPR application Intersystems Cache coding query
So am I doing something wrong or am I assuming a parent/child relationship when there is none? If so how do I tell? Thank you to everyone for your time.
The syntax you are using is correct, but without database schema it's difficult to find an actual error.
What I would suggest, is to use "Query Builder" to create your first few queries in Cache. It's accessible from Management Protal -> Explore -> SQL, "Execute Query" tab, and there is a "Query Builder" button above text area. Don't forget to switch to your application namespace.

odata v4 search example needed

I am trying to learn the OData version 4 protocol and am using the Northwind database to run queries against.
OData 4 introduced the free text search with $search but the queries I've tried all fail.
A couple things I tried (with many variants):
http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$search=%28City%20eq%20Berlin%29
http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$search=City%20eq%20Berlin
http://services.odata.org/V4/Northwind/Northwind.svc/Customers?$search=Berlin
Error message I get is: The query parameter '$search' begins with a system-reserved '$' character but is not recognized.
The official docs don't say much here, and just reference another source for the exact format. However, the format is very cryptic to me...
From the docs, the general idea is http://host/service/Products?$search=blue OR green which seems in line with my examples. So not sure what I'm doing wrong here.
Has anyone successfully used this before and could give me an example? Thanks!
You got an error message from http://services.odata.org/V4/Northwind/Northwind.svc because this service has not been updated to support $search. ODL began to support $search in version 6.1.0. please check 6.1.0 release notes
From the spec, "The $search system query option restricts the result to include only those entities matching the specified search expression. The definition of what it means to match is dependent upon the implementation." Since the match rule is dependent on the service implementation, the service can determine which property or even properties combinations to match the search expression.
This service http://odatae2etest.azurewebsites.net/demo/DefaultService/ has simply implemented $search, and this service choose to have the first string type property to match the search expression.
So for this service, http://odatae2etest.azurewebsites.net/demo/DefaultService/ProductDetails?$search=snack is actually meant to return ProductDetails whose description contains 'snack'.
Otherwise, $search supports AND, OR, NOT operations.

Neo4J: Querying a node index (with wildcards) via the webadmin Data Browser

Using a default index, one can do nodeIndex.get("message", "Hello") for exact matches, or nodeIndex.query("message", "Hel*") for approximate Lucene-based queries. This works correctly for me from Java.
But how do I do approximate queries through the webadmin Data Browser interface? Exact matches work fine, such as:
node:index:nodeIndex:message:"Hello"
but I can't see how to do the wildcard queries. The syntax is shown in the pop-up help panel as:
node:index:[index]:[query]
but I don't know what to put for the [query] part, and can't find any examples of this in the manual or the wiki. Have tried the following without success:
node:index:nodeIndex:"message:Hel*"
node:index:nodeIndex:message:"Hel*"
node:index:nodeIndex:"Hel*"
node:index:nodeIndex:Hel*
This should work:
node:index:nodeIndex:message:Hel*
The queryis message:Hel* so you just append it, more complex queries are also possible.
See the lucene syntax guide.
node:index:nodeIndex:message:Hel* OR message:Wor*
Issue created. https://github.com/neo4j/community/issues/138

Resources