#83 ✓moved_to_github
sdecastelberg

not_group support

Reported by sdecastelberg | April 21st, 2009 @ 03:55 AM

hey,

is something like a 'not_group' available within searchlogic (or in combination with ActiveRecord)?

e.g.: s=System.new_search => #25}>

g=s.conditions.not_group => #g.name_equals="test" => "test" g.descr_equals="test" => "test" s.count => 95

generated sql: SQL (0.5ms) SELECT count("systems".id) AS count_id FROM "systems" WHERE (NOT (("systems"."name" = 'test' AND "systems"."descr" = 'test')))

Comments and changes to this ticket

  • sdecastelberg

    sdecastelberg May 7th, 2009 @ 04:15 AM

    After digging around, trying to find another solution without success I decided to implement that feature within searchlogic. The changes are committed to a fork of searchlogic (http://github.com/sdecastelberg/.... Maybe someone can have a look at it. Feedback is appreciated. (i'm rather new to ruby/ror..)

    The implemented not_group works fine for my needs.

  • Ben Johnson

    Ben Johnson June 3rd, 2009 @ 04:07 AM

    • State changed from “new” to “open”

    Why wouldn't you adjust your conditions to have the opposite effect instead of doing a not_group. Either way, whatever works for you, if you like the not_group solution then I think its fine, but couldn't you accomplish the same thing by adjusting your conditions?

  • sdecastelberg

    sdecastelberg June 3rd, 2009 @ 05:58 PM

    the not_group was initially needed for a monitoring/inventory application to map network components (software and hardware) and provide configuration for different network and application layer scanners.

    For bulk editing, reporting, etc. we needed an exact match search for every single attribute on every model.

    Search Dialog

    *group1

    *SnmpScan (include)
        *oid=ssCpuIdle
        *alarm-threshold=90
    *System (exclude)
        *Status=Test
        *Modified Date start: 2009-01-01
    

    would match the following search (when searching for systems)

    (system.snmp_scan.oid=ssCpuIdle AND system.snmp_scan.alarm_threshold=90) AND NOT (system.state=Test AND modified_date>=2009-01-01)
    

    The attributes are grouped model-wise and can be combined differently (and, or) and the search can be expanded by adding other groups with subgroups.
    The include/exclude flag just sets the not_group attribute on the group, without having to negate all the single attributes.

  • Ben Johnson

    Ben Johnson July 30th, 2009 @ 02:54 AM

    I see what you're saying. But searchlogic deals with single conditions. If you are writing your own named scope for these conditions why not add in the "NOT" yourself? I guess I'm a little confused how you are using searchlogic and how you want to use it.

  • Ben Johnson

    Ben Johnson August 7th, 2009 @ 06:30 PM

    • State changed from “open” to “moved_to_github”

    [state:"moved_to_github" bulk edit command]

Please Sign in or create a free account to add a new ticket.

With your very own profile, you can contribute to projects, track your activity, watch tickets, receive and update tickets through your email and much more.

New-ticket Create new ticket

Create your profile

Help contribute to this project by taking a few moments to create your personal profile. Create your profile ยป

Provides common named scopes and object based searching.

People watching this ticket

Pages