OrientDB2.2 Match Statement, API

72 views
Skip to first unread message

hartmut bischoff

unread,
Jun 29, 2016, 11:20:28 AM6/29/16
to OrientDB
Hi,
I am trying to implement the match-query-syntax either in the java-api (through jruby) or via REST.

This works in Studio:
MATCH {class: Industry, as: Industries} <-- {} <-- { as: Subcategories } RETURN Industries, Subcategories

 
    "result": [
        {
            "@type": "d",
            "@version": 0,
            "Industries": "#21:3",
            "Subcategories": "#28:46",
            "@fieldTypes": "Industries=x,Subcategories=x"
        },
        {
            "@type": "d",
            "@version": 0,
            "Industries": "#23:1",
            "Subcategories": "#26:2",
            "@fieldTypes": "Industries=x,Subcategories=x"
        },  (...)

However "explain" gives a  java.lang.NullPointerException.#

Now my problem.

When submitting the query via REST(batch) it is parsed via json 
and ends up with a Timeout-Error (im my case 

# /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request.rb:427:in `rescue in transmit 
    # /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request.rb:350:in `transmit'
     # /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request.rb:176:in `execute'
     # /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request.rb:41:in `execute'
     # /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/resource.rb:67:in `post'
     # /home/topo/activeorient/lib/rest_operations.rb:63:in `execute'
     # /home/topo/activeorient/lib/model_class.rb:353:in `query_database'
     # /home/topo/activeorient/lib/model_class.rb:316:in `match'
     # ./spec/usecase/contracts_spec.rb:87:in `block (3 levels) in <top (required)>'
     # ------------------
     # --- Caused by: ---
     # Net::ReadTimeout:
     #   Net::ReadTimeout
     #   /home/topo/.rvm/gems/ruby-2.3.1/gems/rest-client-1.8.0/lib/restclient/request.rb:270:in `net_http_do_requestt

when transmitting via the java api using the command method,
jruby-head :012 >   ret= DB.execute { 'MATCH {class: Industry, as: Industries\} <-- {} <-- { as: Subcategories }  RETURN Industries, Subcategories' }
Java::ComOrientechnologiesOrientEnterpriseChannelBinary::OResponseProcessingException: Exception during response processing
from com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.throwSerializedException(com/orientechnologies/orient/client/binary/OChannelBinaryAsynchClient.java:447)
from com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.handleStatus(com/orientechnologies/orient/client/binary/OChannelBinaryAsynchClient.java:382)
from com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.beginResponse(com/orientechnologies/orient/client/binary/OChannelBinaryAsynchClient.java:264)
from com.orientechnologies.orient.client.binary.OChannelBinaryAsynchClient.beginResponse(com/orientechnologies/orient/client/binary/OChannelBinaryAsynchClient.java:152)
from com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(com/orientechnologies/orient/client/remote/OStorageRemote.java:2117)
from com.orientechnologies.orient.client.remote.OStorageRemote.beginResponse(com/orientechnologies/orient/client/remote/OStorageRemote.java:2112)
from com.orientechnologies.orient.client.remote.OStorageRemote$19.execute(com/orientechnologies/orient/client/remote/OStorageRemote.java:1154)
from com.orientechnologies.orient.client.remote.OStorageRemote.networkOperation(com/orientechnologies/orient/client/remote/OStorageRemote.java:168)
from com.orientechnologies.orient.client.remote.OStorageRemote.command(com/orientechnologies/orient/client/remote/OStorageRemote.java:1130)
from com.orientechnologies.orient.core.command.OCommandRequestTextAbstract.execute(com/orientechnologies/orient/core/command/OCommandRequestTextAbstract.java:69)
from java.lang.reflect.Method.invoke(java/lang/reflect/Method.java:498)
from org.jruby.javasupport.JavaMethod.invokeDirectWithExceptionHandling(org/jruby/javasupport/JavaMethod.java:423)
from org.jruby.javasupport.JavaMethod.invokeDirect(org/jruby/javasupport/JavaMethod.java:290)
from RUBY.run_command(/home/topo/orientdb-jruby/lib/orientdb/database.rb:6)
from RUBY.block in execute(/home/topo/activeorient/lib/java-api.rb:306)

As there is a SerializedException-Error,  I suspect, this is simply a matter of escaping some characters.
How is this done? 

Thanks 

hartmut
 

Luigi Dell'Aquila

unread,
Jun 30, 2016, 3:29:22 AM6/30/16
to orient-...@googlegroups.com
Hi Hartmut

I see a backslash before a } in your request

  ret= DB.execute { 'MATCH {class: Industry, as: Industries\} <-- {} <-- { as: Subcategories }  RETURN Industries, Subcategories' }

Could that be the problem?

About the NPE, I'm checking it now

Thanks

Luigi


--

---
You received this message because you are subscribed to the Google Groups "OrientDB" group.
To unsubscribe from this group and stop receiving emails from it, send an email to orient-databa...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Luigi Dell'Aquila

unread,
Jun 30, 2016, 4:44:05 AM6/30/16
to orient-...@googlegroups.com
Hi Hartmut,

I just pushed a fix for the NPE on 2.2.x branch. The fix will be released with next 2.2.4

Thanks

Luigi

Hartmut Bischoff

unread,
Jun 30, 2016, 6:48:58 AM6/30/16
to orient-...@googlegroups.com


Am 30.06.2016 um 09:29 schrieb Luigi Dell'Aquila:
Hi Hartmut

I see a backslash before a } in your request

  ret= DB.execute { 'MATCH {class: Industry, as: Industries\} <-- {} <-- {
as: Subcategories }  RETURN Industries, Subcategories' }

Could that be the problem?

About the NPE, I'm checking it now

Thanks

Luigi


thanks.

The backslash is left out of a "experiment" trying to escape special characters.
I tried  ... replacing ' { '  by " \{ ",
... quoting the classes " MATCH{ class: 'Industry'  ... "
and even "MATCH {class `Industry`...

but did not succeed.
I replaced the "<--" notation with "inE()", but nothing changed.

You can check out the jruby-branch of active-orient to reproduce the error.

bin/orientdb-console
and then ORD.execute or DB.execute
which queries through different api's in a jruby-environmet.

Hartmut Bischoff

unread,
Jun 30, 2016, 6:49:58 AM6/30/16
to orient-...@googlegroups.com
Just saw your message ... thanks very much. Looking forward.

--
finanz coaching
Dr. Hartmut Bischoff
Stuttgart
( http://ficoach.de)

Luigi Dell'Aquila

unread,
Jun 30, 2016, 7:21:50 AM6/30/16
to orient-...@googlegroups.com
Hi Hartmut,

I tried the query on a sample db, but it succeeded, any chance to have a db where you know it fails?

Thanks

Luigi

--

Hartmut Bischoff

unread,
Jun 30, 2016, 7:31:53 AM6/30/16
to orient-...@googlegroups.com
Hi,
I am using a Test-database.
attached


--

---
You received this message because you are subscribed to a topic in the Google Groups "OrientDB" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/orient-database/nBQq8u68mdA/unsubscribe.
To unsubscribe from this group and all its topics, send an email to orient-databa...@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
DEV.gz

hartmut bischoff

unread,
Jul 27, 2016, 12:06:41 PM7/27/16
to orient-...@googlegroups.com

Hi,
just downloaded 2.2.5 community edition and tried to query the database with match.

this is my database-structure  (as posted in DEV.gz)
- - E
    - scanner_result
    - sector_classification
- - V
  - -  Contract
       - Currency
       - Future
       - Option
       - Stock
  - ContractDetail
  - - Sector
       - Category
       - Industry
       - Subcategory

With 2.2.5 the Match-query 
MATCH {class: Industry, as: Industries} <-- {} <-- { as: Subcategories }  RETURN Industries, Subcategories
executes using the REST Interface as well as the Java-Api (with JRuby).

Surprisingly, a slight modification

MATCH {class: Industry, as: Industries} <-- {} <-- {} <-- { as: asset }  RETURN Industries, asset
returns a Timeout-Error on the REST-Interface
but gives a result using the java-api. 

The result-set is about 550 datasets. It took several minutes to perform the query. 
Now I am asking myself, where to start the optimizing-process. 

There are  indexes  sector (uniq, fields name, k)  and  contract (uniq, con_id). There is no Index any Edge-Class.

A "view" to the Database – the query aims to fetch all Stocks related to an Industry:


Any Suggestions?
 

hartmut bischoff

unread,
Jul 27, 2016, 12:26:18 PM7/27/16
to OrientDB
Short Addition:

Performed the query in Studio:


MATCH {class: Industry, as: Industries} <-- {} <-- {} <-- { as: asset } RETURN Industries, asset

1
{
2
    "result": [
3
        {
4
            "@type": "d",
5
            "@version": 0,
6
            "Industries": "#21:3",
7
            "asset": "#44:202",
8
            "@fieldTypes": "Industries=x,asset=x"
9
        },
10
        {
11
            "@type": "d",
12
            "@version": 0,
13
            "Industries": "#23:1",
14
            "asset": "#41:5",
15
            "@fieldTypes": "Industries=x,asset=x"
16
        },
17
        {
18
            "@type": "d",
19
            "@version": 0,
20
            "Industries": "#23:1",
21
            "asset": "#41:28",
22
            "@fieldTypes": "Industries=x,asset=x"
23
        },
24
        {
Query executed in 424.356 sec. Returned 555 record(s). Limit: 2000 (CHANGE IT)

Reply all
Reply to author
Forward
0 new messages