How to change analyzer of an existing Neo4j index using Cypher - indexing

What is the best Cypher command to change the analyzer of an existing index in Neo4j?

To quote from the documentation:
The db.index.fulltext.createNodeIndex and
db.index.fulltext.createRelationshipIndex takes an optional fourth
argument, called config. The config parameter is a map from string to
string, and can be used to set index-specific configuration settings.
The analyzer setting can be used to configure an index-specific
analyzer. The possible values for the analyzer setting can be listed
with the db.index.fulltext.listAvailableAnalyzers procedure.
However, if you are running the Enterprise Edition of neo4j in a clustered environment, there is currently a warning:
Using index-specific settings via the config parameter is
experimental, because these settings currently do not get replicated
in a clustered environment. See the Fulltext Schema Indexes section of
the Operations Manual, for how to configure the default fulltext index
configurations in neo4j.conf.
Here is an example of how to create a fulltext index that uses the "lithuanian" analyzer:
CALL db.index.fulltext.createNodeIndex(
"titlesAndDescriptions",
["Movie", "Book"],
["title", "description"],
{analyzer: "lithuanian"}
)
But there does not seem to be a way, using Cypher, to change the analyzer of an existing fulltext index. In fact, even if that were possible, it may not be a good idea. Since the contents of an existing index would have been created using the previous analyzer and any new additions to the index would be made with the new analyzer, index lookups could lead to very strange or error-prone results. It would be better to create an new fulltext index instead.

Related

rename database field in upgrade wizard of an extension in TYPO3 11

I have an upgrade wizard (TYPO3 11) which changes the data of a table.
This is done with the querybuilder:
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content');
$queryBuilder
->update('tt_content')
->set('CType', 'newCType')
->where($queryBuilder
->expr()
->eq('CType',$queryBuilder->createNamedParameter('oldCType')))
->execute();
But I also need to rename a field in a table:
ALTER TABLE tt_content RENAME COLUMN tx_myext_old_field TO tx_myext_new_field;
I can't find any documentation or example of doing this with the querybuilder.
The normal way woult be to provide a ext_tables.sql in your extension. This is read by TYPO3 to build a virtual "database scheme" how it should look.
The database schema analyser will than provide the information, and database alteration are suggested.
You could add a database must be up to date constraint to your upgrade wizard, that way it is ensured that the field is changed.
DTL is a special task, and you have to provide the correspinng queries yourself ... which are different for different dbms systems. So using the normal way would be recommended.
The platform/driver may have some generig helper methods providing some native sql parts for doing stuffs like that. The may be possible to provide custom stuff based on SchemaMigrator or SchemaManger etc - but thats low-level stuff.
doctrine/dbal directly do not really provide these DTL as API. And the querybuilder is not meant to be used for that low level stuff at all. That's the wrong tool for such tasks.
You can also change columns of core tables that way, by providing simply the table name and the column defintion only for the field you want to change.
The official way is to handle this with ext_tables.sql and the database schema analyser.
See: https://docs.typo3.org/m/typo3/reference-coreapi/main/en-us/ExtensionArchitecture/FileStructure/ExtTablesSql.html
The concept of renaming a column could not work:
On installing the extension all new fields are generated (or should be generated if in composer mode). And as the extension should work with the new columns they are already defined.
And before the upgrade wizard could rename a column these columns are existent already which prevents a rename.
In the end I do a content copy enhancing the update query like this:
$queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)
->getQueryBuilderForTable('tt_content');
$queryBuilder
->update('tt_content')
->set('CType', 'newCType')
->set('tx_myext_newfield1',$queryBuilder->quoteIdentifier('tx_myext_oldfield1'),false)
->set('tx_myext_newfield2',$queryBuilder->quoteIdentifier('tx_myext_oldfield2'),false)
->where($queryBuilder
->expr()
->eq('CType',$queryBuilder->createNamedParameter('oldCType')))
->executeStatement();

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"])

Neo4j APOC clear manual index

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?

Lucene search doesn't return results on Orientdb server restart

I am using OrientDB 2.0.9 with a Java application. I am using graph Java API to create graph instance. I am facing an issue with Lucene index search.
I have entered some data in a vertex and then if I do a Lucene search, I get the result. Then I restarted orientdb server and then same Lucene search doesn't return any data inserted in last server run. Whereas if I do a normal field search without Lucene index, I can see all result.
final OrientGraphFactory gFactory = new OrientGraphFactory("db_path").setupPool(0, 10);
OrientGraph graphDB = gFactory.getTx();
graphDB.setUseLightweightEdges(true);
OrientDynaElementIterable result = (OrientDynaElementIterable) graphDB.command(
new OCommandSQL("select from KnowledgeElement where description LUCENE ?")
).execute(searchText);
I have also tried this with 2.1.4 server.
Some more information which could help: I have created vertex and lucene index by running below commands through console:
CREATE class KnowledgeElement extends V
CREATE property KnowledgeElement.description String
ALTER property KnowledgeElement.description collate ci
CREATE index KnowledgeElement.description on KnowledgeElement (description collate ci) FULLTEXT ENGINE LUCENE
Any help would be highly appreciated. I am unable to get it work and therefore I am forced to replace lucene search by simple like search.
I am still clueless about the problem. Any help is highly appreciated.

Change Index in OrientDB

I'm new on OrientDB. How can I change the searching index to Hash Indexing (Database:GratefulDeadConcerts) . I don't understand that what is written in Orient DB Dpcs. I use the Orient DB Studio.
Provided the index was created as a Hash type index. You can look it up by using this command : select from index:<index-name> where key = <key> as explained and documented in OrientDB Manual Indexes.