Feature #9909

Search in project and its subprojects by default

Added by ed boel over 5 years ago. Updated 4 months ago.

Status:ClosedStart date:
Priority:NormalDue date:
Assignee:Jean-Philippe Lang% Done:

0%

Category:Search engine
Target version:3.4.0
Resolution:Fixed

Description

The default search scope when in a project is now only the selected project.
In my setup there are about 25 different projects, so it is easy if the search scope would always be 'all projects' or 'this and its subprojects'. Is it possible to add a configuration option to enable that?

9909_set_default_search_scope_to_project_and_its_subprojects.patch Magnifier (3.51 KB) Marius BALTEANU, 2017-04-11 00:07

9909_default_search_scope_v2.patch Magnifier (5.47 KB) Marius BALTEANU, 2017-04-13 00:12


Related issues

Duplicated by Redmine - Feature #23403: Make default search scope configurable Closed
Duplicated by Redmine - Feature #22125: Make Search default to current project and sub projects Closed

Associated revisions

Revision 16641
Added by Jean-Philippe Lang 4 months ago

Search in project and its subprojects by default (#9909).

History

#1 Updated by John Wilcox over 5 years ago

We are using Redmine internally in our organization and the current search function is confusing for our users also. We are using Redmine for task management (e.g. no RCS and code development stuff) and we have built an hierarchy of projects based on the organizational structure. For example, CIO has three departements beneath him and when searching, by default he would like to search every "project" under him. As it now, he has to make too many clicks to get where he wants and on the other hand the default Redmine search method is not suitable for us at all. So if possible, please make it configurable (preferrably redmine-wide).

#2 Updated by Robert Rath over 5 years ago

Actually there does exist this capability already. When searching from the initial search entry field (usually in the top right of the screen) you only have the choice of one project.

When you actually perform the initial search you are taken to the Redmine search page which gives you the option to search one of;

a) current project,
b) my projects, or
c) all projects.

So a nice to have feature change would be to place 'my projects' and 'all projects' in the initial project choice but not actually necessary.

#3 Updated by André Bachmann over 4 years ago

A quick and dirty way to change this Redmine behaviour is to edit apps/controller/search_controller.rb and edit in class SearchController < ApplicationController the various statements (for example, if you want to change the default search scope to global, you should change the else statement from @project to nil).

projects_to_search =
      case params[:scope]
      when 'all'
        nil
      when 'my_projects'
        User.current.memberships.collect(&:project)
      when 'subprojects'
        @project ? (@project.self_and_descendants.active.all) : nil
      else
        #@project
        nil
      end

#4 Updated by Dotan Cohen about 4 years ago

I very much agree that either searching all subprojects should be the default, or that the default should be configurable.

#5 Updated by Ernő Rigó about 4 years ago

My solution was to update the search form via the site theme. You should create javascripts/theme.js with the following content:

function customSearch() {
    var node = document.getElementById("quick-search");
    node.innerHTML = 
        "<form actuion='/search' method='GET'>" +
        "<a href='/search'>Search:</a>" +
        "<input type=text name=q>" +
        "</form>";
};

if (window.jQuery) { 
  $(window).load(customSearch);
}

Other search options can be easily added via form fields.

#6 Updated by Marc M. about 3 years ago

+1

#7 Updated by Chi Song Tao about 1 year ago

I need this function, too.

Can the default search be configurable for each project?

#8 Updated by Toshi MARUYAMA about 1 year ago

  • Duplicated by Feature #23403: Make default search scope configurable added

#9 Updated by Marius BALTEANU 6 months ago

Many of our projects are organised in a main project with multiple subprojects. For these projects, our users use mostly the "Issues" page from the parent project because it offers a great visibility over the issues, a lot of filters and options (like group by project). Without any subproject filter, a query returns issues from parent project and its subprojects. But if you're using the search input, the results returned are only from the current project (parent in my case). Each time when I search something I've the expectation to get results from the subprojects too. A usual case is when I want to search for an issue after subject (is faster to use the search instead of adding the subject filter ).

The attached patch changes the search behaviour in order to include results from "<Project and its subprojects" by default. In this way, query scope and search scope are consistent between them.

I'm not sure if it is worth it to add a setting in admin for this.

#10 Updated by Go MAEDA 6 months ago

  • Target version set to Candidate for next major release

I think that the suggested patch by Marius can improve consistency.

We see issues of subprojects by default in issues page (Default value of Setting.display_subprojects_issues is True). So including issues from subprojects in search results by default is very natural.

#11 Updated by Marius BALTEANU 6 months ago

Go MAEDA wrote:

We see issues of subprojects by default in issues page (Default value of Setting.display_subprojects_issues is True). So including issues from subprojects in search results by default is very natural.

Oh, I didn't know that displaying subprojects issues on main projects is configurable (my bad). In this case, I think that it'll be better to rename the option in something like "Include subprojects issues on main projects issues and search by default" and make the patch to take into account the setting. In this way, it'll be consistent in both cases (with option enabled and disabled).

What do you think, Go MAEDA?

#12 Updated by Go MAEDA 6 months ago

  • Target version deleted (Candidate for next major release)

Marius BALTEANU wrote:

Go MAEDA wrote:

We see issues of subprojects by default in issues page (Default value of Setting.display_subprojects_issues is True). So including issues from subprojects in search results by default is very natural.

In this case, I think that it'll be better to rename the option in something like "Include subprojects issues on main projects issues and search by default" and make the patch to take into account the setting. In this way, it'll be consistent in both cases (with option enabled and disabled).

Absolutely agree. It will be even better.

#13 Updated by Marius BALTEANU 6 months ago

Thanks, I'll update the patch soon.

#14 Updated by Marius BALTEANU 5 months ago

Here it is the updated patch: 9909_default_search_scope_v2.patch

#15 Updated by Go MAEDA 5 months ago

  • Target version set to 3.4.0

The patch 9909_default_search_scope_v2.patch improve usability, and consistensy between search engine and issue tracking. Marius BALTEANU.

Setting target version to 3.4.0.

#16 Updated by Jean-Philippe Lang 4 months ago

  • Subject changed from set default search scope of a project to Search in project and its subprojects by default
  • Status changed from New to Closed
  • Assignee set to Jean-Philippe Lang
  • Resolution set to Fixed

I've made a simple change to search by default in project and its subprojects. It's based on an helper that can be easily patched, rather than changing the logic in the search controller. Unlike the search engine, the setting is (almost) specific to issues display_subprojects_issues, I prefer not to reuse it in this case. If it's needed, we'll add a specific setting for the default search scope.

#17 Updated by Mischa The Evil 3 months ago

  • Duplicated by Feature #22125: Make Search default to current project and sub projects added

Also available in: Atom PDF