<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;">Wolfgang, Thanks for the reply. The N threads means I need to be able to query/check the list very often. The through put is undetermined, but could be as high as several hundred lookups per second. It seems you agree that using a stateful session would require me to process each request serially, unless I wanted to spin up several copies of my facts. That would seem inefficient.<br>

<br><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0pt 0pt 0pt 0.8ex; border-left: 1px solid rgb(204, 204, 204); padding-left: 1ex;"><div class="im">
Date: Mon, 18 Apr 2011 10:05:29 +0200<br>
From: Wolfgang Laun &lt;<a href="mailto:wolfgang.laun@gmail.com" target="_blank">wolfgang.laun@gmail.com</a>&gt;<br>
Subject: Re: [rules-users] Searching a list - Is Drools the answer?<br>
To: Rules Users List &lt;<a href="mailto:rules-users@lists.jboss.org" target="_blank">rules-users@lists.jboss.org</a>&gt;<br>
<br></div><div><div></div><div class="h5">
It&#39;s possible that putting the &quot;constants&quot; into rules will result in a rule<br>
building process that&#39;s more complex than what you need to do if this data<br>
is in facts. Notice that your Object_1 has to participate in (at least)<br>
three different matching scenarios, which is a simple thing for a fact, but<br>
may need three rules if FirstName and LastName are literals in rules.<br>
<br>
A (serially) reusable Stateful Session would need to be set up with the 10k<br>
facts. A search request enters an object, produces results, and retracts the<br>
request; then the session is ready for the next request. (The N threads you<br>
are talking about results from some overall application context?)<br>
<br>
Regards<br>
Wolfgang<br>
<br>
2011/4/18 Drools User &lt;<a href="mailto:drools2030@gmail.com" target="_blank">drools2030@gmail.com</a>&gt;<br>
<br>
&gt; I have been using Drools for several years, but just with constraints<br>
&gt; (rules) on 1 set of objects at a time. Think many rules, few facts in a<br>
&gt; stateless session. I have been given a new project at the office which<br>
&gt; requires having about 10-100k facts and few rules. These 10k facts would be<br>
&gt; basically constants, a list of things I need to search on each request. I<br>
&gt; would then need to load a single object, based on a request to see if my<br>
&gt; request object matched the list. It is somewhat a simple search, but I need<br>
&gt; to be able to inject aliases and search partial matches in addition to exact<br>
&gt; matches. A generic example:<br>
&gt;<br>
&gt; List:<br>
&gt; Object 1 (FirstName=John, LastName=Smith)<br>
&gt; Object 2 (FirstName=Will, LastName=Smith)<br>
&gt; Object 3 (FirstName=Jon, LastName=Smith)<br>
&gt;<br>
&gt; Request/Use Case:<br>
&gt; LastName=Smith, would return all 3 objects, but marked as single match<br>
&gt; LastName=Smith, Firstname =John, Would return object 1, as exact double<br>
&gt; match, and Object 3 a nickname double match<br>
&gt; LastName=Smith, Firstname =J, Would return object 1 and 3, as partial match<br>
&gt;<br>
&gt; In the second request, I need to run all names through a nickname DB/list<br>
&gt; to explode the name into multiple search patterns. Possibly using (<br>
&gt; <a href="http://code.google.com/p/nickname-and-diminutive-names-lookup/" target="_blank">http://code.google.com/p/nickname-and-diminutive-names-lookup/</a>)<br>
&gt;<br>
&gt; Hopefully that explains a bit about the problem.<br>
&gt;<br>
&gt; So to the question, there are a few ways to solve this. The simplest is<br>
&gt; just SQL from a DB, but this proves to be slow to search all the ways I<br>
&gt; need. I need sub second response times. An in memory DB is another possible<br>
&gt; solution we are looking at. Not to think of Drools as the golden hammer, but<br>
&gt; this smells like something I can use Drools for. My first thought was to<br>
&gt; load the &quot;List&quot; as facts into a stateful session. My concern is wouldn&#39;t I<br>
&gt; need N copies of the list loaded to have N threads? This would be<br>
&gt; inefficient if so. I know rules aren&#39;t copied per working memory, but is<br>
&gt; there a way to create a master working memory for facts to use?<br>
&gt;<br>
&gt; So my second thought is to convert my List into rules so they would only be<br>
&gt; stored once in the system, regardless of number of threads using the engine.<br>
&gt;<br>
&gt; What do you guys think, am I on the right track with this? Is Drools a good<br>
&gt; way to do this or is there something better I have overlooked?<br>
&gt;<br>
&gt; Thank you for taking the time.<br>
&gt; -Drools user<br></div></div></blockquote></div><br>
</blockquote></div><br>