Executing my Test class on a new DB with the following block at the end: 

Iterator<Vertex> it = graph2.getVertices("Government.itemid", 45).iterator
();
        while( it.hasNext() ) {
            Vertex temp = it.next();
            System.out.println("Vertex : " + temp.toString());
        }


Gives :


Vertex : v(Government)[#12:1]
Vertex : v(Government)[#12:0]

Which are the two Government Vertices creates before we get to that loop.

So from what I can gather, the index is being created correctly, and stuff 
is being stored in it. 
What I think is happening is that  getVertexByKey(final String iKey, Object 
iValue) is not retrieving the result. Maybe this method, which should 
return only one Vertex, does not work in the kind of index I am creating , 
and maybe will only work with an Index with a UNIQUE constraint ?   Also 
the method documentation does not state what happens if more than one 
Vertex is found (returns only the first Vertex? return null?) 



On Wednesday, December 3, 2014 7:49:07 AM UTC, Curtis Mosters wrote:
>
> What happens if you do:
>
> graph2.getVertices("Government.itemid", 45)
>
> If that does not help, have a look on my Real case import code: 
> http://www.kwoxer.de/2014/11/12/daten-import-via-java-orientdb-real-beispiel-tutorial/
> Maybe there is something that helps.
>
> You could also try to change the way you create the index. Maybe instead 
> of the current way do it with a method and a non-graph database object 
> (just look at the example code):
>
> void createIndex(String className, INDEX_TYPE indexType, String 
> propertyName, String indexName) {
>          db.getMetadata().getSchema().getClass(className).createIndex(
> propertyName, indexType, indexName);
>      }
>
>
>
> Am Mittwoch, 3. Dezember 2014 00:44:37 UTC+1 schrieb syshex:
>>
>> It is a clean install, running only on my laptop, started with :  
>>
>> rui@jupiter ~/Software/orientdb-community-2.0-M3/bin $ ./orientdb.sh start
>> Starting OrientDB server daemon...
>> Password: 
>>
>> I have made no configuration changes what so ever, with the exception of 
>> editing  orientdb.sh  in this way :
>>
>> ORIENTDB_DIR="/home/rui/Software/orientdb-community-2.0-M3/"
>> ORIENTDB_USER="rui"
>>
>> Also on the first post of this thread I posted a java source file the 
>> reproduces what I have described.
>> Hope this helps. 
>>
>> Thanks
>> Rui
>>
>>
>> On Tuesday, December 2, 2014 11:17:36 PM UTC, Lvc@ wrote:
>>>
>>> Are you running distributed?
>>>
>>> Lvc@
>>>
>>>
>>> On 2 December 2014 at 22:00, syshex <[email protected]> wrote:
>>>
>>>> There you go 
>>>>
>>>>
>>>>
>>>>
>>>> On Tuesday, December 2, 2014 8:58:34 PM UTC, syshex wrote:
>>>>>
>>>>> sure, how do I do that ? 
>>>>>
>>>>> On Tuesday, December 2, 2014 8:54:47 PM UTC, Curtis Mosters wrote:
>>>>>>
>>>>>> Hi could you please show the indices in the Studio? Thanks
>>>>>>
>>>>>> Am Dienstag, 2. Dezember 2014 15:04:29 UTC+1 schrieb syshex:
>>>>>>>
>>>>>>> Hi !
>>>>>>>
>>>>>>> I create the following Vertex type and index :
>>>>>>>
>>>>>>> OrientGraphNoTx graph = factory.getNoTx();
>>>>>>> *graph*
>>>>>>>
>>>>>>> *.createVertexType("Government");graph.createKeyIndex("itemid", 
>>>>>>> Vertex.class, new Parameter<>("class", 
>>>>>>> "Government"));graph.createKeyIndex("nif", Vertex.class, new 
>>>>>>> Parameter<>("class", "Government"));*
>>>>>>> graph.commit();  // Just Because ...
>>>>>>>
>>>>>>>
>>>>>>> Then I go on to create a Vertex of that type :
>>>>>>>
>>>>>>> OrientGraph graph = factory.getTx();
>>>>>>> Vertex node = graph.addVertex("class:Government");
>>>>>>> *node**.setProperty("itemid", 45);*
>>>>>>> node.setProperty("nif", "1234567890");
>>>>>>> node.setProperty("description", "Somewhere");
>>>>>>> graph.commit() ; 
>>>>>>>
>>>>>>> I then search for  :
>>>>>>>
>>>>>>> Vertex exists = graph2.getVertexByKey("Government.itemid", 45);
>>>>>>>
>>>>>>> And exists == Null ; therefore not found. 
>>>>>>>
>>>>>>> I even tried defining the properties of the Gorvernment vertex type, 
>>>>>>> like this : 
>>>>>>>
>>>>>>> OrientGraphNoTx graph = factory.getNoTx();
>>>>>>> OrientVertexType vertexType = graph.createVertexType("Government");
>>>>>>> *vertexType**.createProperty("itemid", OType.LONG);*
>>>>>>> *vertexType**.createProperty("nif", OType.STRING);*
>>>>>>> graph.createKeyIndex("itemid", Vertex.class, new Parameter<>("class"
>>>>>>> , "Government"));
>>>>>>> graph.createKeyIndex("nif", Vertex.class, new Parameter<>("class", 
>>>>>>> "Government"));
>>>>>>> graph.commit();
>>>>>>>
>>>>>>> and do the same: 
>>>>>>>
>>>>>>>         OrientGraph graph2 = factory.getTx();
>>>>>>>         Vertex node = graph2.addVertex("class:Government");
>>>>>>>         node.setProperty("itemid", 45);
>>>>>>>         node.setProperty("nif", "1234567890");
>>>>>>>         node.setProperty("description", "Somewhere");
>>>>>>>         graph2.commit() ;
>>>>>>>
>>>>>>>         graph2 = factory.getTx();
>>>>>>>         Vertex exists = graph2.getVertexByKey("Government.itemid", 
>>>>>>> 45);
>>>>>>>
>>>>>>>
>>>>>>>         if (exists == null) {
>>>>>>>             System.out.println("Does not Exist");
>>>>>>>             node = graph2.addVertex("class:Government");
>>>>>>>             node.setProperty("itemid", 45);
>>>>>>>             node.setProperty("nif", "1234567890");
>>>>>>>             node.setProperty("description", "Somewhere");
>>>>>>>             graph2.commit() ;
>>>>>>>         } else {
>>>>>>>             System.out.println("Exist already");
>>>>>>>         }
>>>>>>>
>>>>>>>
>>>>>>> I always end up with two vertex entries on the DB , as can be see 
>>>>>>> from the attached Image,
>>>>>>>
>>>>>>> I also attach a test class for this problem. 
>>>>>>>
>>>>>>> I'm running 2.0-M3 on linux and the dependencies for the TestRun 
>>>>>>> class attached are :
>>>>>>>
>>>>>>> "com.orientechnologies" % "orientdb-client" % "2.0-M3",
>>>>>>>   "com.orientechnologies" % "orientdb-enterprise" % "2.0-M3",
>>>>>>>   "com.orientechnologies" % "orient-commons" % "2.0-M1",
>>>>>>>   "com.orientechnologies" % "orientdb-core" % "2.0-M3",
>>>>>>>   "com.orientechnologies" % "orientdb-graphdb" % "2.0-M3",
>>>>>>>   "com.tinkerpop.blueprints" % "blueprints-core" % "2.6.0",
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>
>>>>>>>  -- 
>>>>
>>>> --- 
>>>> 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