As mentioned before, my test-suite-Vertices have the following structure:
- V
  - - - Contract
    - - ContractDetail
    - - Sector
      - - Category
        - Industry
        - Subcategory

Contracts got an unique Index "Con_id" and Sector "name".


names are unique on class-level only.
My "quick&dirty" solution was to extend the index on Sector to "name, k", 
where k is a shortcut of the class.

 93         orientdb.create_properties( :Sector, name: {type: :string}, k: 
{type: :string})
 94         orientdb.create_index( :Sector,  name: 'sectorindex', on: 
[:name, :k], type: :unique  )




Then I can use the atomic upsert  (with ruby code:)

136             sub_cat_record = ActiveOrient::Model::Subcategory.upsert( 
set: { :k => 'S' },
137                                  where: { :name => 
contract.contract_detail.subcategory }) do | new_sub_cat |
138                 category_record = 
 ActiveOrient::Model::Category.upsert( set: { :k => 'C' },
139                                         where: { :name => 
contract.contract_detail.category }) do | new_category |
140                         industry_record = 
ActiveOrient::Model::Industry.upsert( set: { :k => 'I' },
141                                               where: { :name => 
contract.contract_detail.industry }) do | new_industry |


Obviously this is a sloppy workaround.

Is there a way to specify an Index which is unique on class-level ? 

-- 

--- 
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