Lucene search doesn't return results on Orientdb server restart - lucene

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.

Related

Neo4j community edition uses AllNodesSan instead of NodeByLabelScan

I am using Neo4j community edition 4.4.11 to build an application.
I have created some Image nodes in my database and performed the following query.
I was expecting neo4j to use NodeByLabelScan
PROFILE MATCH (n:Image) RETURN n LIMIT 25
However, it scanned all database to find Image nodes...
Is this supposed?
Thank you.
can Someone tell me why this happened?
Even with index on :Image, it will do a nodescan because you are not using an index.
Try this, if you have Image.name that exists.
create index imageNameIdx for (i:Image) on i.name
Then
PROFILE MATCH (i:Image) WHERE i.name = <something> RETURN n
It will show you that it is using that index (NodeIndexSeek)

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

How to change analyzer of an existing Neo4j index using Cypher

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.

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?

OrientDB: text searching using gremlin

I am using OrientDB and the gremlin console that comes with.
I am trying to search a pattern in text property. I have Email vertices with ebodyText property. The problem is that the result of querying with SQL like command and Gremlin language is quite different.
If I use SQL like query such as:
select count(*) from Email where eBodyText like '%Syria%'
it returns 24.
But if I query in gremlin console such as:
g.V.has('eBodyText').filter{it.eBodyText.matches('.*Syria.*')}.count()
it returns none.
Same queries with a different keyword 'memo' returns 161 by SQL but 20 by gremlin.
Why does this behave like this? Is there a problem with the syntax of gremlin command? Is there a better way to search text in gremlin?
I guess there might be a problem of setting properties in the upload script which uses python driver 'pyorient'.
Python script used to upload the dataset
Thanks for your help.
I tried with 2.1.15 and I had no problem.
These are the records.
EDITED
I added some vertexes to my DB and now the count() is 11
QUERY:
g.V.has('eBodyText').filter{it.eBodyText.contains('Syria')}.count()
OUTPUT:
==>11
Hope it helps.