Thanks Hartmut!  That's awesome.

But I still have questions/issues....

#1.  "query = OrientSupport::OrientQuery.new where:  "out('HasContent').item 
IN ['Quartal','Land']""

IN [..,..] works as a OR and not an AND, right?

I wanted to find everything that has both words.  Ideally, I'm asking this 
more simple question but *my real query will be to find all the books with 
a large set of attributes *that I figured I'd go through the graph in and 
out to find.

Maybe that's a more relevant question?

*HOW TO MOST EFFICIENTLY FIND ALL THE VERTICES IN SOME SET THAT ARE POINTED 
TO BY A LIST OF OTHER VERTICES?*

#2.  'IN' is slow but '=' (equals) is fast

SELECT FROM NM WHERE s = 'ELEPHANT'     << 0.033 seconds
SELECT FROM NM WHERE s IN 'ELEPHANT'     << 8.761 seconds


#3.  In my case there are fewer distinct words than there are books so I 
want to go the other way.    2 >> n

i.e. Which books contain these 2 words?   But I have 200k words and 10m 
books.


I've certainly exhausted myself with this....   

Here are some things that I've tried...  (I've literally tried more than 
100 queries@)

I tried to use union, set, etc.

SELECT expand($c) let $a = (SELECT in('b_w') FROM W WHERE s = 'elephant'), 
$b = (SELECT in('b_w') FROM W WHERE s = 'fence'), $c = unionall($a, $b)

Seems that 'union' was cut

SELECT FROM (SELECT in('b_w').out('b_w') FROM W WHERE s = 'elephant') WHERE 
s = 'fence'

SELECT FROM (SELECT expand(in('b_w')) FROM W WHERE s = 'elephant') WHERE 
out('b_w').s = 'fence'

Maybe I shouldn't be starting at W (the word) but that's the faster one for 
me.

I could also start by book category or year of printing or author or 
...........    I just want to find a list of books from all these 
attributes that the books are tagged with.

On Thursday, August 27, 2015 at 3:42:40 PM UTC+3, hartmut bischoff wrote:
>
> Hi,
> I used your example to calibrate the ruby-interface active-orient (and 
> could improve several things).
> Have you set proper indexes to speed up the query? 
>
>
> Here is the Active-Orient-Solution (as always outlined as RSpec-Test) .... 
> all tests are passing.
>
>
> 49   context "Books Words example" , focus: true do
> 50     before(:all) do
> 51       @r.delete_class :book
> 52       Book = @r.create_vertex_class :book
> 53       Book.create_property( :title, type: :string, index: :unique )
> 54       @r.delete_class :word
> 55       Word= @r.create_vertex_class :word
> 56       Word.create_property( :item , type: :string, index: :unique )
> 57       @r.delete_class :has_content
> 58       HC= @r.create_edge_class :has_content
> 59 
>  60     end
> 61     it "check structure" do
> 62       expect( @r.class_hierachie( base_class: 'V').sort ).to eq [Book.
> new.classname, Word.new.classname]
> 63       expect( @r.class_hierachie( base_class: 'E') ).to eq [HC.new.
> classname]
> 64     end
> 65 
>  66     it "put test-content" do
> 67      fill_database = ->( sentence, this_book ) do
> 68        sentence.split(' ').each do |x|
> 69          this_word = Word.update_or_create where: { item: x }
> 70          this_edge = HC.create_edge from: this_book, to: this_word 
>  71        end
> 72       end
> 73       words = 'Die Geschäfte in der Industrie im wichtigen 
> US-Bundesstaat New York sind im August so schlecht gelaufen wie seit mehr 
> als sechs Jahren nicht mehr Der entsprechende Empire-State-Index fiel 
> überraschend von plus  Punkten im Juli auf minus 14,92 Zähler Dies teilte 
> die New Yorker Notenbank Fed heut mit Bei Werten im positiven Bereich 
> signalisiert das Barometer ein Wachstum Ökonomen hatten eigentlich mit 
> einem Anstieg auf 5,0 Punkte gerechnet'
> 74       this_book =  Book.create title: 'first'
> 75       fill_database[ words, this_book ]
> 76       expect( Word.count ).to be > 10
> 77      
> 78      words2 = 'Das Bruttoinlandsprodukt BIP in Japan ist im zweiten 
> Quartal mit einer aufs Jahr hochgerechneten Rate von Prozent geschrumpft Zu 
> Jahresbeginn war die nach den USA und China drittgrößte Volkswirtschaft der 
> Welt noch um  Prozent gewachsen Der Schwächeanfall wird auch als Rückschlag 
> für Ministerpräsident Shinzo Abe gewertet der das Land mit einem Mix aus 
> billigem Geld und Konjunkturprogramm aus der Flaute bringen will Allerdings 
> wirkte sich die heutige Veröffentlichung auf die Märkten nur wenig  aus da 
> Ökonomen mit einem schwächeren zweiten Quartal gerechnet hatten'
> 79      this_book =  Book.create title: 'second'
> 80      fill_database[ words2, this_book ]
> 81      expect( Word.count ).to be  > 100 
>  82     end
> 83     it "Subquery Initialisation" do
> 84       query = OrientSupport::OrientQuery.new where:  
> "out('HasContent').item 
> IN ['Quartal','Land']"
> 85       result= Book.query_database query
> 86       expect( result).to be_a Array
> 87       expect( result).to have_at_least(1).item
> 88       queried_book =  result.first
> 89       expect( queried_book ).to be_a ActiveOrient::Model::Book
> 90       expect( queried_book.title ).to eq 'second'
> 91       
> 92     end
> 93   end
>
>
>
>

-- 

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