Project

General

Profile

Bug #2604

searching for hosts with digits can lead to unexpected results

Added by David Schmitt almost 6 years ago. Updated almost 6 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
Search
Target version:
Difficulty:
Triaged:
No
Bugzilla link:
Pull request:
Team Backlog:
Fixed in Releases:
Found in Releases:

Description

repro

  • In a foreman containing current reports, search for "foobar$i", where $i is the current day of month. For example, today is the 3rd of june, so search for "foobar03".

expected results

  • All hosts matching "foobar03" are displayed as result.

actual results

  • All hosts matching "foobar03" and all hosts with a last_report date of 2013/06/03 are displayed (which is, like, 99% of them)

remarks

Many of our hostnames follow the common /$prefix\d\d/ pattern. When searching for fooblah03, and it is currently the 3rd of the month, this will lead to almost all hosts being returned in the search, making the search results pretty unusable.

This can be seen easily when looking at the generated SQL:

[...] WHERE (("hosts"."name" ILIKE '%foobar03%' OR ("hosts"."last_report" >= '2013-06-03 00:00:00' AND "hosts"."last_report" < '2013-06-04 00:00:00') OR "hosts"."ip" ILIKE '%foobar03%' [...]

I guess the searcher should avoid trying to match words with non-numeric parts against dates.

Associated revisions

Revision 273b110a (diff)
Added by Amos Benari almost 6 years ago

fixes #2604 searching for hosts with digits can lead to unexpected results

Revision 8e0d7ee3 (diff)
Added by Amos Benari almost 6 years ago

fixes #2604 searching for hosts with digits can lead to unexpected results
(cherry picked from commit 273b110af4c3f9416ec237f4880ce0406d5f795c)

History

#1 Updated by Dominic Cleal almost 6 years ago

  • Category set to Search
  • Assignee set to Amos Benari

#2 Updated by David Schmitt almost 6 years ago

current installed s/w versions:

  • foreman-1.1stable-3.el6.noarch
  • foreman-postgresql-1.1stable-3.el6.noarch
  • foreman-proxy-1.1stable-1.el6.noarch
  • libselinux-ruby-2.0.94-5.3.el6.x86_64
  • ruby-1.8.7.352-7.el6_2.x86_64
  • ruby-augeas-0.4.1-1.el6.x86_64
  • ruby-devel-1.8.7.352-7.el6_2.x86_64
  • rubygem-abstract-1.0.0-2.el6.noarch
  • rubygem-actionmailer-3.0.20-1.el6.noarch
  • rubygem-actionpack-3.0.20-1.el6.noarch
  • rubygem-activemodel-3.0.20-1.el6.noarch
  • rubygem-activerecord-3.0.20-1.el6.noarch
  • rubygem-activeresource-3.0.20-1.el6.noarch
  • rubygem-activesupport-3.0.20-1.el6.noarch
  • rubygem-acts_as_audited-2.0.0-1.el6.noarch
  • rubygem-ancestry-1.3.0-1.el6.noarch
  • rubygem-apipie-rails-0.0.13-1.el6.noarch
  • rubygem-arel-2.0.10-1.el6.noarch
  • rubygem-audited-3.0.0.rc1-1.el6.noarch
  • rubygem-audited-activerecord-3.0.0.rc1-1.el6.noarch
  • rubygem-builder-2.1.2-1.el6.noarch
  • rubygem-bundler-1.0.15-1.el6.noarch
  • rubygem-daemon_controller-0.2.6-1.el6.noarch
  • rubygem-erubis-2.6.6-1.el6.noarch
  • rubygem-fastthread-1.0.7-2.el6.x86_64
  • rubygem-i18n-0.5.0-1.el6.noarch
  • rubygem-jquery-rails-1.0.19-1.el6.noarch
  • rubygem-json-1.4.6-1.el6.x86_64
  • rubygem-mail-2.3.3-2.el6.noarch
  • rubygem-mime-types-1.18-1.el6.noarch
  • rubygem-multi_json-1.2.0-1.el6.noarch
  • rubygem-net-ldap-0.3.1-1.el6.noarch
  • rubygem-oauth-0.4.7-1.el6.noarch
  • rubygem-passenger-3.0.17-2.el6.1.x86_64
  • rubygem-passenger-native-3.0.17-2.el6.1.x86_64
  • rubygem-passenger-native-libs-3.0.17-2.el6.1.x86_64
  • rubygem-pg-0.13.2-2.el6.x86_64
  • rubygem-polyglot-0.3.3-1.el6.noarch
  • rubygem-rabl-0.7.5-1.el6.noarch
  • rubygem-rack-1.2.5-4.el6.noarch
  • rubygem-rack-mount-0.6.14-1.el6.noarch
  • rubygem-rack-test-0.5.7-2.el6.noarch
  • rubygem-rails-3.0.20-1.el6.noarch
  • rubygem-railties-3.0.20-1.el6.noarch
  • rubygem-rake-0.9.2.2-2.el6.noarch
  • rubygem-rdoc-3.12-2.el6.x86_64
  • rubygem-rest-client-1.6.7-1.el6.noarch
  • rubygem-ruby2ruby-2.0.1-1.el6.noarch
  • rubygem-ruby_parser-3.0.1-2.el6.noarch
  • rubygems-1.8.10-1.el6.noarch
  • rubygem-safemode-1.2.0-1.el6.noarch
  • rubygem-scoped_search-2.4.0-1.el6.noarch
  • rubygem-sexp_processor-4.1.2-1.el6.noarch
  • rubygem-sinatra-1.0-2.el6.noarch
  • rubygem-stomp-1.2.2-1.el6.noarch
  • rubygem-thor-0.14.6-2.el6.noarch
  • rubygem-treetop-1.4.10-1.el6.noarch
  • rubygem-tzinfo-0.3.32-1.el6.noarch
  • rubygem-uuidtools-2.1.1-1.el6.noarch
  • rubygem-will_paginate-3.0.3-1.el6.noarch
  • ruby-irb-1.8.7.352-7.el6_2.x86_64
  • ruby-libs-1.8.7.352-7.el6_2.x86_64
  • ruby-mysql-2.8.2-1.el6.x86_64
  • ruby-rdoc-1.8.7.352-7.el6_2.x86_64
  • ruby-shadow-1.4.1-13.el6.x86_64

#3 Updated by Ohad Levy almost 6 years ago

  • Status changed from New to Feedback

this is actually the expected behaviour, when you don't specify the field you want to search on, e.g.

host ~ foobar01

then it would do a full free text search based on all possible fields.

#4 Updated by Amos Benari almost 6 years ago

solution should be something as suggested here:
https://github.com/wvanbergen/scoped_search/issues/51#issuecomment-16176544

add :only_explicit => true to the date fields.

#5 Updated by Amos Benari almost 6 years ago

  • Status changed from Feedback to Assigned

Moved back to assigned.
I want to fix it because I don't want the date field to be part of the "free text" search,
it leads to creative parsing as date.
See link in my previous comment.

#6 Updated by Dominic Cleal almost 6 years ago

  • Status changed from Assigned to Ready For Testing
  • Target version set to 1.2.0

#7 Updated by Amos Benari almost 6 years ago

  • Status changed from Ready For Testing to Closed
  • % Done changed from 0 to 100

Also available in: Atom PDF