Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7498681
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T19:33:36+00:00 2026-05-29T19:33:36+00:00

My requirement is to match tags. In the example, this particular HourConstraint checks the

  • 0

My requirement is to match tags. In the example, this particular HourConstraint checks the TeacherHour assigned to Hour(23).

Specifically, it checks TeacherHour.attributes["tags"] for the values ["asst_ct","teacher_john_smith"] and detects atleast one match, two in this case (both "asst_ct" and "teacher_john_smith") .

TeacherHour:
  id: 47
  assigned_hour: Null
  attributes:Map<List<String>>
    "tags":["asst_ct","no_strenuous_duties","kinda_boring","teacher_john_smith"]
    "another_attribute":[...]

HourConstraint:
   hour: Hour(23)
   attribute: "tags"
   values_list: ["asst_ct","teacher_john_smith"]

Question: How do I detect the presence (true or false) of common elements between two lists?

Drools Expert has memberOf and contains, but they check a scalar vs a collection, never a collection vs a collection.

I see two potential ways:

  1. introduce a function boolean isIntersecting(list,list) and tell Drools to use that for truth checking
  2. Implement TeacherHour.attributes[] as a string instead of a list and HourConstraint.valueslist as a regular expression that can match that list
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T19:33:38+00:00Added an answer on May 29, 2026 at 7:33 pm

    There are a few options. Most straight forward is to use the Collections class to do that for you:

    rule X
    when
        $t: TeacherHour( )
        HourConstraint( Collections.disjoint( $t.attributes["tags"], values_list ) == false )
    ...
    

    If this is something you would use often in your rules, then I recommend wrapping that function in a pluggable operator, supported by Drools. Lets say you name the operator “intersect”, you can then write your rules like this:

    rule X
    when
        $t: TeacherHour( )
        HourConstraint( values_list intersect $t.attributes["tags"] )
    ...
    

    A third option, is to use “from”, but that is less efficient in runtime as it causes iterations on the first list:

    rule X
    when
        $t: TeacherHour( )
        $tag : String() from $t.attributes["tags"]
        exists( HourConstraint( values_list contains $tag ) )
    ...
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Requirement is this ... We have our 3 web-applications deployed in RHEL-5 server, we
Requirement is like: I want to take input values from user in frame but
I use vim. I have a requirement to use 80 or fewer columns. This
I have a requirement where I need to match text like testuser or joeperson
I have a requirement to match U.S. postal addresses during an import process. The
I have a requirement to match all the incoming requests and filter out certain
I have a requirement to provide a suggested match between data in two database
Need a regular expression to match { and } . Here is my requirement.
I've got a requirement that is basically this. If I have a string of
I have the following requirement: - I have many (say 1 million) values (names).

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.