1

Since the result1 is equal to result2 I would assume that both usages are correct and equivalent. An interesting fact is that RavenDB's statistics total results is only correct when the query is build in the same way as for result2. But can anybody explain me in detail why the query as built in result1 is wrong or a bad practice despite the results are equivalent? Any idea why the statistics total results isn't working?

result1 = query1
             .Where(first filter)
             .Intersect()
             .Search(second filter)
             .Search(third filter)
             .ToList();

Is interpreted as (first filter) INTERSECT ((second filter) OR (third filter)) by lucene.

result2 = query2.Where(first filter)
.Search(second filter, options:SearchOptions.And)
.Search(third filter).Search(third filter, options:SearchOptions.Or)
.ToList();

Is interpreted as (first filter) AND ((second filter) OR (third filter)) by lucene.

Daniel Gartmann
  • 11,678
  • 12
  • 45
  • 60
  • You need to show the actual query. Note that INTERSECT does something very different than AND. AND is for index entries matches, INTERSECT is for document matches. In general, don't use INTERSECT – Ayende Rahien Feb 22 '15 at 09:22
  • The first query is: "OrganizationType:Club INTERSECT ( Name:(Foo) ShortName:(Foo))" and the second query is "OrganizationType:Club AND ( Name:(Foo) ShortName:(Foo))". I am very interested to know how the intersect function works and how the "matches" are determined? I couldn't find any detailed documentation about that. – Daniel Gartmann Feb 22 '15 at 11:59
  • INTERSECT is working by matching based on the RavenDB document id. That is relevant if you have multiple entries per document. See the full details here: http://issues.hibernatingrhinos.com/issue/RavenDB-51 – Ayende Rahien Feb 23 '15 at 11:34

0 Answers0