Conditional Searching #13995
Replies: 2 comments 4 replies
-
Well, to start with, what is the logic of You are doing full text search on the company id? Why no use That said, if you are searching by all of them in this manner, is there a reason not to have a single index covering both of them?
The above will search just on orders, but you can then apply that with |
Beta Was this translation helpful? Give feedback.
-
That's the thing - I don't want units that have matches in both, I want units in either. "Show me all units that match the search criteria OR units that belong to companies that match the search criteria" |
Beta Was this translation helpful? Give feedback.
-
Here's the scenario I am working with
A Unit is an abstract class from which we have a handful of concrete implementations (Project, Location, etc). Often, the client doesn't know information about the Unit, but they know something about the Company (which itself is an abstract class that also has several concrete implementations) that owns the Unit.
I have indexes for both Units & Companies that uses
WhereEntityIs
to cover all types since they all share the same underlying fields.When a client searches, they are saying "Find me any unit that matches this search criteria and find me all units that belong to any companies that match the search criteria."
Every Unit has a reference to its
CompanyId
as there are too many units to store directly in the company record.The code I have is as follows
This works fine if the companyQuery returns any companies, but fails with
Cannot search on empty searchTerms array.
if there aren't any matches.It really isn't a huge deal to execute the
companyQuery
& then modify theunitQuery
if we get records back, but I'm trying to figure out if this can be done in a single trip to Raven.Beta Was this translation helpful? Give feedback.
All reactions