Hi Montrazul,

What version of OrientDB do you use? is that reproducible on current
snapshot?

Best regards,
Artem Orobets

* Orient Technologiesthe Company behind OrientDB*


2014-05-11 10:31 GMT+03:00 Montrazul <[email protected]>:

> But if you do so, how do you add new values to your collection?
>
> Without the index i did it like that:
>
> public void setProperty(Vertex vertex, String key, String value) {
>      Set<String> keys = vertex.getPropertyKeys();
>  List<String> values = null;
>  if(keys.contains(key)) {
>  values = (List<String>)vertex.getProperty(key);
> values.add(value);
> } else {
>  values = new ArrayList<String>();
> values.add(value);
> }
>  vertex.setProperty(key, values);
> }
>
> And with the index you cant do that:
>
> Exception in thread "main"
> com.orientechnologies.orient.core.exception.ODatabaseException: Error on
> saving record in cluster #11
>  at
> com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:1052)
> at
> com.orientechnologies.orient.core.tx.OTransactionNoTx.saveRecord(OTransactionNoTx.java:82)
>  at
> com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:333)
> at
> com.orientechnologies.orient.core.db.record.ODatabaseRecordTx.save(ODatabaseRecordTx.java:42)
>  at
> com.orientechnologies.orient.core.record.ORecordAbstract.save(ORecordAbstract.java:333)
> at
> com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1381)
>  at
> com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1370)
> at
> com.orientechnologies.orient.core.record.impl.ODocument.save(ODocument.java:1359)
>  at
> com.tinkerpop.blueprints.impls.orient.OrientElement.save(OrientElement.java:150)
> at
> com.tinkerpop.blueprints.impls.orient.OrientElement.save(OrientElement.java:133)
>  at
> com.tinkerpop.blueprints.impls.orient.OrientElement.setProperty(OrientElement.java:99)
> Caused by: java.lang.NullPointerException
>  at
> com.orientechnologies.orient.core.index.hashindex.local.OLocalHashTable.put(OLocalHashTable.java:212)
> at
> com.orientechnologies.orient.core.index.engine.OLocalHashTableIndexEngine.put(OLocalHashTableIndexEngine.java:150)
>  at
> com.orientechnologies.orient.core.index.OIndexDictionary.put(OIndexDictionary.java:44)
> at
> com.orientechnologies.orient.core.index.OIndexDictionary.put(OIndexDictionary.java:29)
>  at
> com.orientechnologies.orient.core.tx.OTransactionNoTx.addIndexEntry(OTransactionNoTx.java:186)
> at
> com.orientechnologies.orient.core.index.OIndexTxAware.put(OIndexTxAware.java:80)
>  at
> com.orientechnologies.orient.core.index.OIndexTxAware.put(OIndexTxAware.java:36)
> at
> com.orientechnologies.orient.core.index.OClassIndexManager.processIndexUpdateFieldAssignment(OClassIndexManager.java:398)
>  at
> com.orientechnologies.orient.core.index.OClassIndexManager.processSingleIndexUpdate(OClassIndexManager.java:369)
> at
> com.orientechnologies.orient.core.index.OClassIndexManager.updateIndexEntries(OClassIndexManager.java:156)
>  at
> com.orientechnologies.orient.core.index.OClassIndexManager.onRecordAfterUpdate(OClassIndexManager.java:131)
> at
> com.orientechnologies.orient.core.hook.ODocumentHookAbstract.onTrigger(ODocumentHookAbstract.java:266)
>  at
> com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.callbackHooks(ODatabaseRecordAbstract.java:1274)
> at
> com.orientechnologies.orient.core.db.record.ODatabaseRecordAbstract.executeSaveRecord(ODatabaseRecordAbstract.java:1029)
>  ... 14 more
> Exception in thread "Thread-1" java.lang.NullPointerException
> at
> com.orientechnologies.orient.core.index.hashindex.local.OLocalHashTable.saveState(OLocalHashTable.java:369)
>  at
> com.orientechnologies.orient.core.index.hashindex.local.OLocalHashTable.flush(OLocalHashTable.java:1141)
> at
> com.orientechnologies.orient.core.index.engine.OLocalHashTableIndexEngine.flush(OLocalHashTableIndexEngine.java:94)
>  at
> com.orientechnologies.orient.core.index.OIndexAbstract.flush(OIndexAbstract.java:116)
> at
> com.orientechnologies.orient.core.index.OIndexManagerAbstract.flush(OIndexManagerAbstract.java:170)
>  at
> com.orientechnologies.orient.core.index.OIndexManagerAbstract.close(OIndexManagerAbstract.java:282)
> at
> com.orientechnologies.orient.core.storage.OStorageAbstract.close(OStorageAbstract.java:120)
>  at
> com.orientechnologies.orient.core.storage.OStorageEmbedded.close(OStorageEmbedded.java:70)
> at
> com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.doClose(OLocalPaginatedStorage.java:713)
>  at
> com.orientechnologies.orient.core.storage.impl.local.paginated.OLocalPaginatedStorage.close(OLocalPaginatedStorage.java:672)
> at com.orientechnologies.orient.core.Orient.shutdown(Orient.java:155)
>  at
> com.orientechnologies.orient.core.OrientShutdownHook.run(OrientShutdownHook.java:28)
>
>
>
>
>
>
> Am Samstag, 10. Mai 2014 18:11:03 UTC+2 schrieb Valentin Popov:
>>
>> Yup, it is possible
>>
>> But you need create properties before you add some values to such
>> properties, other case ODB cant create index for properties that already
>> stored on DB.
>>
>> Something like that
>>
>>
>> ItemType type = ItemType.USER;
>>
>>
>> OrientVertexType ovt = graph.getVertexType(type.getClassName());
>>
>>
>> IndexedProperty indexProperty = IndexedProperty.EMAIL;
>>  String fieldName = indexProperty.getIndexKey();
>> String iName = type.getClassName()+"."+fieldName;
>>
>>
>>  ovt.createProperty(fieldName, OType.EMBEDDEDLIST, OType.STRING);
>>  graph.getRawGraph().commit();
>>
>>
>>  ovt.createIndex(iName, INDEX_TYPE.UNIQUE, fieldName);
>>
>>  graph.getRawGraph().commit();
>>
>>
>>
>> I am also interested in indexing properites of type EMBEDDEDLIST.
>>
>> Am Mittwoch, 7. Mai 2014 08:10:40 UTC+2 schrieb Valentin Popov:
>>>
>>> Luca, hi
>>>
>>> Is it possible to search in index via such properties,
>>> like OType.EMBEDDEDLIST  contains [admin, administrator, superuser] can I
>>> search record only by name = admin?
>>>
>>> Regards,
>>> Valentin
>>>
>>> вторник, 6 мая 2014 г., 23:45:22 UTC+4 пользователь Lvc@ написал:
>>>>
>>>> Hi,
>>>> You should call:
>>>>
>>>> g.getVertexType("MyType").createProperty("name", OType.EMBEDDEDLIST,
>>>> OType.STRING);
>>>>
>>>> Lvc@
>>>>
>>>>
>>>> Lvc@
>>>>
>>>>
>>>> On 6 May 2014 20:06, Marc Tigges <[email protected]> wrote:
>>>>
>>>>> Hello,
>>>>>
>>>>> i need a property for a vertex containing multiple values, so i tried
>>>>> to find out
>>>>> if i can create something like that. I found this:
>>>>>
>>>>> this.graph.createProperty(vertexType, "name", OType.EMBEDDEDLIST);
>>>>>
>>>>> But in the documentation is written:
>>>>>
>>>>> this is a container and needs the parameter *linked-type* or
>>>>> *linked-class*
>>>>>
>>>>> But i need to store Strings inside the list.
>>>>>
>>>>> How can i create a property of a type like collection containing
>>>>> strings?
>>>>>
>>>>> --
>>>>>
>>>>> ---
>>>>> 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 a topic in the
>> Google Groups "OrientDB" group.
>> To unsubscribe from this topic, visit https://groups.google.com/d/
>> topic/orient-database/xWmAWQOPKwY/unsubscribe.
>>  To unsubscribe from this group and all its topics, send an email to
>> [email protected].
>>
>> For more options, visit https://groups.google.com/d/optout.
>>
>>
>> Regards,
>> Valentin Popov
>>
>>
>>
>>
>>  --
>
> ---
> 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