Closed shrawankher closed 4 years ago
Hi @shrawankher do you have a script to reproduce this issue?
Thanks
Hi @wolf4ood, Thank you so much for reply
const DBClient = Orientjs.OrientDBClient;
const clientObj = await DBClient.connect(dbConfig);
const pool = await client.sessions(dbConfig);
let session = await pool.acquire();
const results = await session.query(select from INDEX:XYZ where KEY="PQR").all();
Hi @wolf4ood Getting similar error when query fired from orient DB studio and console
Hi @wolf4ood The script to reproduce this issue
CREATE CLASS Person EXTENDS V CREATE PROPERTY Person.name STRING CREATE PROPERTY Person.height Integer CREATE PROPERTY Person.weight Integer CREATE INDEX Person.name ON Person(name) FULLTEXT ENGINE LUCENE SELECT FROM Person WHERE name LUCENE "test*" // works SELECT FROM INDEX:Person.name where KEY="PQR" // fails with error in console/studio/orientjs
Let me know if we need to move this issue to OrientDB forum. I will attempt to report and seek there.
Hi @vikram-shityalkar @shrawankher
equals operator cannot be applied in lucene indexes.
You should use lucene search functions
https://orientdb.com/docs/3.0.x/indexing/Full-Text-Index.html#searchindex
for example
SELECT FROM Person WHERE SEARCH_INDEX("Person.name", "PQR") = true
let me know if that helps
Thanks
@wolf4ood Thank you for the reply.
The SEARCH_INDEX function works with the mentioned scenario but it will not work with the following.
Create a new class that extends Person.
CREATE CLASS Employee EXTENDS Person
Check the employee class scheme in studio, you will see Person.name index is present. Insert some records in Employee class. Use the following query:
select from Employee where SEARCH_INDEX('Person.name','Jay') = true
The above query throws error:
com.orientechnologies.orient.core.exception.OCommandExecutionException: Cannot evaluate SEARCH_INDEX('Person.name', 'Jay') = true: no index defined DB name="test"
If I create an additional index on Employee e.g. Employee.ID, following query works.
select from Employee where SEARCH_INDEX('Employee.ID','1') = true
Hi @shrawankher
that's because the engine check if the index is declared on the class in this case
select from Employee where SEARCH_INDEX('Person.name','Jay') = true
Why do you want to use manually the index name?
Thanks
Hi @wolf4ood,
I have vertex which has some default properties that I want to inherit in extended vertex.
In the current example, the Employee extends Person, so Employee gets all properties from Person, also indexes. I am creating vertexes on demand, I am thinking to use the vertex's capability to use Index defined at the base. i.e. Using the same index name for newly extended vertex, no need to create new indexes again.
Hi @vikram-shityalkar
that's ok, in your case you can use the SEARCH_CLASS
function if you have only 1 index or SEARCH_FIELDS
example
select from Employee where SEARCH_CLASS("Jay") = true
or
select from Employee where SEARCH_FIELDS(["name"],"Jay") = true
and it should work with polymorphic class/indexes.
I guess the SEARCH_INDEX
api does not
Let me know if this helps
Thanks
Hi @wolf4ood,
Thank you, this does help. SEARCH_FIELDS function is working, I have multiple indexes on vertex. I will try to integrate into the main codebase and will perform some unit test cases. Thanks again.
@wolf4ood you can close this issue. Thank you for help.
@vikram-shityalkar
Thanks
Server Configuration are as follow: OrientDB Docker image tag : 3.0.1 Type of Indexing used is FULLTEXT ENGINE LUCENE
Getting Error OrientDB.RequestError: java.lang.String cannot be cast to com.orientechnologies.orient.core.index.OCompositeKey