Neo4j APOC clear manual index - indexing

I use Neo4j 3.4.0 Community Edition with APOC apoc-3.4.0.1-all.jar
I'm looking for the way how to properly via Cypher/APOC clear manual index.
Right now I'm trying something like that:
CALL apoc.index.relationships('HAS_VALUE_ON', '*:*')
YIELD rel
WITH rel
CALL apoc.index.removeRelationshipByName('HAS_VALUE_ON', rel)
RETURN true
but I don't know how to properly provide the *:* predicate in order to retrieve all of the relationships from the index.
The current query fails with the following error:
Neo.ClientError.Security.Forbidden: Write operations are not allowed
for user 'neo4j' with FULL restricted to READ.
How to properly clear manual index with Cypher/APOC?

Related

Can't create fulltext index in neo4j 4.2.X

According to this documentation, in neo4j 4.2.X one can create freetext indexes as follows:
CREATE FULLTEXT INDEX my_index
FOR (n:MYNODETYPE) ON EACH (n.label)
Yet when I run this query, I get the following error message:
Invalid input 'I': expected whitespace, comment, '=', node labels, MapLiteral, a parameter, a parameter (old syntax), a relationship pattern, ',', FROM GRAPH, USE GRAPH, CONSTRUCT, LOAD CSV, START, MATCH, UNWIND, MERGE, CREATE UNIQUE, CREATE, SET, DELETE, REMOVE, FOREACH, WITH, CALL, RETURN, UNION, ';' or end of input (line 1, column 17 (offset: 16))
"CREATE FULLTEXT INDEX my_index"
I've seen this related post which had a similar error, but the accepted answer says that the syntax I'm using should be valid in neo4j 4.X. I'm running neo4j 4.2.7, community edition (confirmed by calling dbms.components()).
What am I doing wrong?
I am looking at the docs and they seem a bit different. Try the following:
CREATE FULLTEXT INDEX titlesAndDescriptions FOR (n:MYNODETYPE) ON EACH [n.label]
It seems the above syntax is for Neo4j 4.3+. Syntax for previous versions of Neo4j is as follows:
CALL db.index.fulltext.createNodeIndex("titlesAndDescriptions", ["MyNodeType"], ["label"])

Is there a way to update a calculation view through a query on SAP HANA?

I'm working on updating hundreds of calculation views on SAP HANA.
I should update (for every calculation view) the last aggregation/projection columns : Keep flag = True.
There's a way, by updating XML Code of every calculation view file Like below:
<attribute id="EQUNR" order="3" attributeHierarchyActive="false"
displayAttribute="false" keepFlag="true">
<descriptions defaultDescription="EQUNR"/>
But, my question is, is there a way to update this Keep Flag through a query on SQL Console ?
if not, is there any other method you suggest guys ?
Every idea matters, Thank you folks
There is no way to achieve this via SQL.
Although you may be able to author a regex expression that matches some of the target XML tags, there’s no way of correctly updating the repository tables storing the source XML (if you’re using the HANA classic repository).
For HANA 2 HDI files no DB command can change the source code as these are not stored in the database.
Beyond this technical issue, it’s probably not a good idea to apply a flag that changes query semantics as a batch update.

Determine/Find underlying SQL field type of a Django Field

Is there an easy way to determine or find the underlying SQL field type of a Django Field, for any of the supported by default database backends? I have searched on the web and there is no documentation over how the Django fields are represented in SQL in each of the supported databases. The only way for me to see the underlying SQL field type, is to run the mysqlmigrate command of manage.py and examine the SQL code.
The type depends on the database backend, so you need to get a db connection first:
from django.db import connection
and now you can look up the field via the model Meta API:
my_field = MyModel._meta.get_field('my_field_name')
and use its db_type method:
my_field.db_type(connection)
which will return something like "varchar(10)".
Be sure you really need to do this, though. Usually this information is only useful inside migrations.

Tagging an SQL Query

I would like to be able to tag an SQL query somehow, so I can relate the query execution to the web request that triggered the query. I already have a unique request id, that I tag my logs and other monitoring with, so I can easily do a complete trace across the weblogs and new relic for example.
But when I look at a report of long running SQL queries for example, I cannot trace that back to the request that triggered the SQL Query. I would really like to be able to tag the query with my request id somehow.
I can't find anything online. When I search I just find blogs about storing tags and tag clouds in SQL. Not really what I need.
Hope the question makes sense.
This is a very interesting post...
I hope, adding an extra nullable parameter to your stored procedure(s) will ensure that the profiler will catch the unique id passed during a call (in the trace) whether you use that parameter inside the procedure or not (i.e. to do something meaningful...like inserting into an audit table with unique id, procedure name, timestamp etc).
But I think that will make life difficult as you now have to update all your procedures.
If you already have logging turned on (web server) and it captures the same unique id in its request (log file) along with a timestamp then you probably can code a small utility app that reads the log file and find matching entries in the traced table by the timestamp alone.
The only thing that might go wrong is if your web server and database server have differeing times (you need to offset your calculation accordingly).
I don't know if this will help but it is certainly a very interesting project and I am hoping somebody have experienced this thing and came up with a nice solution.
Will be closely watching this post if such a solution exists....
All the best...
If I understand correctly, you want to follow up the query execution in Activity Monitor. But have you considered using a DMV or SQL PROFILER ?
In my opinion, your best bet would be to wrap it in a stored proc. This way you will be able to FILTER your trace only for this object. Here's an example of a simple select and the same select wrapped in stored proc named sproc1 :
As you can see in this image, you can start a SQL PROFILER trace and filter it on the ObjectName. You can then add other column like CPU, StartTime, ...
If you can't use a stored proc, then I would suggest to insert a comment before the exec like this:
/* ID1234 */
select * from table1
Then use SQL PROFILER the same way but you now filter on the TextData using your ID
Here the result :

How can I programmatically run arbitrary SQL statements against my Hibernate/HSQL database?

I'm looking for a way to programmatically execute arbitrary SQL commands against my DB.
(Hibernate, JPA, HSQL)
Query.createNativeQuery() doesn't work for things like CREATE TABLE.
Doing LOTS of searching, I thought I could use the Hibernate Session.doWork().
By using the deprecated Configuration.buildSesionFactory() seems to show that doWork won't work.
I get "use lacks privilege or object not found" for all the CREATE TABLE statements.
So, what other technique is there for executing arbitratry SQL statements?
There were some notes on using the underlying JDBC Statement, but I haven't figure out how to get a JDBC Connection object from Hibernate to try that.
Note that the hibernate.hbm2ddl.auto=create setting will NOT work for me, as I have ARRAY[] columns which it chokes on.
I don't think there is any problem executing a create table statement with a Hibernate native query. Just make sure to use Query.executeUpdate(), and not Query.list() or Query.uniqueResult().
If it doesn't work, please tell us what happens when you execute it, and join the full stack trace of the exception and the SQL query you're executing.
"use lacks privilege or object not found" in HSQL may mean anything, for example existence of a table with the same name. Error messages in HSQL are completely misleading. Try listing your tables using DatabaseMetadata - you have probably already created the table.