>From a quick inspection of the source code
<https://github.com/orientechnologies/orientdb/blob/master/graphdb/src/main/java/com/tinkerpop/blueprints/impls/orient/OrientBaseGraph.java>,
it would appear that that method is intended for use with single-part keys
only. The only method that appears to handle multiple key-value pairs would
be getVertices.  Try using this call instead:

graph.getVertices( "A", new Object[]{"s","i"}, new Object[]{"A", 1 } )

A quick read of the code implies that getVertices() will loop through the
available indexes and use a matching index, if available.

- Craig -

On Mon, Apr 27, 2015 at 3:23 AM, Adrian Mihalcea <[email protected]>
wrote:

> Hi all,
>
> I've been trying to use the Java API to obtain indexed records and got
> myself in a bit of a problem.
>
> I'm using version 2.0.8
>
> on OrientBaseGraph there is a method called getVertexByKey.
>
> javadoc for it says:
>
> *Vertex
> com.tinkerpop.blueprints.impls.orient.OrientBaseGraph.getVertexByKey(String
> iKey, Object iValue)*
>
>
> *Lookup for a vertex by id using an index.*
> *Example: Vertex v = getVertexByIndex("V.name", "name", "Jay"); *
> *Parameters:*
> * iKey Name of the indexed property*
> * iValue Field value*
> *Returns:*
> * Vertex instance if found, otherwise null*
>
> Apart from the apparent wrong example in JavaDoc, that refers to a non
> existent (probably older) getVertexByIndex method, the method seems to work
> fine in these conditions:
> 1. index is unique
> 2. index is created for a single field
>
> while first point is understandable as the method returns a single Vertex
> node, for the second point I need help in expressing the key for indexes on
> multiple fields.
>
> I have a node A with two fields s of type string and i of type integer.
> Index name is A.s_i
> In the web UI whenever I write the query as:
> select rid from index:A.s_i where key = ['A', 1]
> the query succeeds and has expected result.
>
> if I attempt to retrieve the value with the same key from java, using
> getVertexByKey, I don't get any results:
>
> My attempts so far in writing the key are:
>
> graph.getVertexByIndex("A.s_i", new Object[]{"A", 1})
> graph.getVertexByIndex("A.s_i", "['A',1]")
> also tried with a List<Object> as key, but no results.
>
> Looks like I'm fighting the API so it is probably something that I'm doing
> wrong, but I'm a bit lost about what is the right path. Could you please
> help me with this?
>
> Thank you,
> Adrian
>
> --
>
> ---
> 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 [email protected].
> For more options, visit https://groups.google.com/d/optout.
>

-- 

--- 
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 [email protected].
For more options, visit https://groups.google.com/d/optout.

Reply via email to