Elasticsearch as a datastore for rules


(Sandeep Srinivasa) #1

hi,

I'm trying to use Elasticsearch as a datastore for rules (modeled as
documents). The challenge is that a search returns many documents, which
means many "rules" matched the query - I am trying to find a way to get
Elasticsearch to rank them automagically.

For example, I have four documents

id:1
title: sss
team: a
not-team:

id:2
title: sss1
team: a,b (multivalued fields)
not-team:

id:3
title sss2
team:
not-team:a

id:4
title: sss3
team:
not-team:

(remember that not-team means that a person is NOT in team )

Now,searching for "team:a" should return three documents 1,2,4 (note that 4
is also returned, since it does not say anything about "a" which implies a
match) - but ranked with 1 >> 2 >> 4 starting from most specific to least
specific.

I do expect to have a validation layer in my application as well, but it
would be great if this can be done at the Elasticsearch level. This would
be perfect as a NoSQL like application of Elasticsearch.

could someone point me in the right direction ?

thanks!
-sandeep


(Igor Motov) #2

Would something like https://gist.github.com/12a45d7e928a1693406b work for
you?

On Tuesday, July 10, 2012 12:37:40 AM UTC-4, Sandeep Srinivasa wrote:

hi,

I'm trying to use Elasticsearch as a datastore for rules (modeled as
documents). The challenge is that a search returns many documents, which
means many "rules" matched the query - I am trying to find a way to get
Elasticsearch to rank them automagically.

For example, I have four documents

id:1
title: sss
team: a
not-team:

id:2
title: sss1
team: a,b (multivalued fields)
not-team:

id:3
title sss2
team:
not-team:a

id:4
title: sss3
team:
not-team:

(remember that not-team means that a person is NOT in team )

Now,searching for "team:a" should return three documents 1,2,4 (note that
4 is also returned, since it does not say anything about "a" which implies
a match) - but ranked with 1 >> 2 >> 4 starting from most specific to
least specific.

I do expect to have a validation layer in my application as well, but it
would be great if this can be done at the Elasticsearch level. This would
be perfect as a NoSQL like application of Elasticsearch.

could someone point me in the right direction ?

thanks!
-sandeep


(Sandeep Srinivasa) #3

On Tuesday, 10 July 2012 19:32:53 UTC+5:30, Igor Motov wrote:

Would something like https://gist.github.com/12a45d7e928a1693406b work
for you?

This was very helpful - thank you very much for taking the time. I was
thinking of needing to build a custom plugin for scoring, but I see that I
can probably model them as boosts. This was an example of a pretty simple
usecase, but the rules are expected to pretty pathological. I am just
concerned about the complexity of queries.

I will post back, once I have investigated this in some depth.

thanks!
-sandeep


(system) #4