searching in custom fields
Moderators: Developer, Contributor
searching in custom fields
Hi there,
is there a way to use the search function on view_al_bug_page on all custom_fields?
Thx for your help
edit: I dont want to use Filter_on_custom_fields, i just have too many of them.
is there a way to use the search function on view_al_bug_page on all custom_fields?
Thx for your help
edit: I dont want to use Filter_on_custom_fields, i just have too many of them.
I´m sure it cane be done by modifiying filter_api.php.
It should work when adding
"$t_textsearch_where_clause = ...
OR ($t_custom_field_string_table.value LIKE '%$c_search%'))";
$t_textsearch_wherejoin_clause = ....
OR ($t_custom_field_string_table.value LIKE '%$c_search%'))";
and in the loop :
$t_id_join = $t_id_join . " INNER JOIN $t_custom_field_string_table ON $t_custom_field_string_table.bug_id = $t_bug_table.bug_text_id";
unfortunately, my sql-knowledge is not the best.
I also tried it with the LEFT JOIN statement from the 'sort by cuztom field',
but i think there must be made a little change to get it work.
It should work when adding
"$t_textsearch_where_clause = ...
OR ($t_custom_field_string_table.value LIKE '%$c_search%'))";
$t_textsearch_wherejoin_clause = ....
OR ($t_custom_field_string_table.value LIKE '%$c_search%'))";
and in the loop :
$t_id_join = $t_id_join . " INNER JOIN $t_custom_field_string_table ON $t_custom_field_string_table.bug_id = $t_bug_table.bug_text_id";
unfortunately, my sql-knowledge is not the best.
I also tried it with the LEFT JOIN statement from the 'sort by cuztom field',
but i think there must be made a little change to get it work.
If somebody is interested in the solution for my question:
To find a searchstring in the custom fields, just modifiy the sql statement in filter_api.php:
Code: Select all
$custom_query = " $t_bug_table.id IN ( SELECT DISTINCT bug_id from mantis_custom_field_string_table where value LIKE '%$c_search%')";
$t_textsearch_where_clause = "((summary LIKE '%$c_search%')
OR ($t_bug_text_table.description LIKE '%$c_search%')
OR ($t_bug_table.id = '$c_search_int')
OR ($custom_query))";
$t_textsearch_wherejoin_clause = "((summary LIKE '%$c_search%')
OR ($t_bug_text_table.description LIKE '%$c_search%') OR ($t_bug_table.id LIKE '%$c_search%')
OR ($t_bugnote_text_table.note LIKE '%$c_search%')
OR ($custom_query))";Attention:
I think there was somewhere a warning about searching in all custom fields (didnt found it now ). If there are a lot of bugs to search in, the new sql-statement will cost the sql-server much more time.
Re: searching in custom fields
Hello Frederic,
Thanks for that.
I've tried to implement on my code, but i obtain an "ERROR #401".
I guess that i haven't paste your code at the good place, or maybe, not adapt it correctly.
May i ask u more indications about the place to paste it on filter_api.php.
Thanks again.
Ben
Thanks for that.
I've tried to implement on my code, but i obtain an "ERROR #401".
I guess that i haven't paste your code at the good place, or maybe, not adapt it correctly.
May i ask u more indications about the place to paste it on filter_api.php.
Thanks again.
Re: searching in custom fields
This is the way it should be implemented in version 1.1.8.
Search for similar code and replace with below:
# Simple Text Search - Thanks to Alan Knowles
if ( !is_blank( $t_filter['search'] ) ) {
$c_search = db_prepare_string( $t_filter['search'] );
$c_search_int = db_prepare_int( $t_filter['search'] );
$custom_query = " $t_bug_table.id IN ( SELECT DISTINCT bug_id from mantis_custom_field_string_table where value LIKE '%$c_search%')";
$t_textsearch_where_clause = '(' . db_helper_like( 'summary', "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.description", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information", "%$c_search%" ) .
" OR ( $t_bug_table.id = '$c_search_int' ) OR ( $custom_query ) )";
$t_textsearch_wherejoin_clause = '(' . db_helper_like( 'summary', "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.description", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_table.id", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note", "%$c_search%" ) .
" OR ( $custom_query ) )";
Search for similar code and replace with below:
# Simple Text Search - Thanks to Alan Knowles
if ( !is_blank( $t_filter['search'] ) ) {
$c_search = db_prepare_string( $t_filter['search'] );
$c_search_int = db_prepare_int( $t_filter['search'] );
$custom_query = " $t_bug_table.id IN ( SELECT DISTINCT bug_id from mantis_custom_field_string_table where value LIKE '%$c_search%')";
$t_textsearch_where_clause = '(' . db_helper_like( 'summary', "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.description", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information", "%$c_search%" ) .
" OR ( $t_bug_table.id = '$c_search_int' ) OR ( $custom_query ) )";
$t_textsearch_wherejoin_clause = '(' . db_helper_like( 'summary', "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.description", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bug_table.id", "%$c_search%" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note", "%$c_search%" ) .
" OR ( $custom_query ) )";
Re: searching in custom fields
Any clue how to do this in version 1.2.10 (0r 11/12)?
Really would like to have similar function available
Really would like to have similar function available
-
knall
Re: searching in custom fields
The very last note in this issue worked like a charm. http://www.mantisbt.org/bugs/view.php?id=7183
I'm using 1.2.12.
Thanks
I'm using 1.2.12.
Thanks
-
bloodlessz
- Posts: 5
- Joined: 28 Sep 2012, 07:41
Re: searching in custom fields
Hi to all,
Can someone tell me how to deploy this so i can search in custom fields?
I have download the api, and add it to \api\soap\ and nothing happens. Am i doing something wrong?
Thank you
Can someone tell me how to deploy this so i can search in custom fields?
I have download the api, and add it to \api\soap\ and nothing happens. Am i doing something wrong?
Thank you
Re: searching in custom fields
just to know that the moudsen patch for Mantis 1.2.4 (see attached file) can be applied to version 1.2.11 doing the following:
In the file core/filter_api.php search for:
$t_textsearch_where_clause .= '( ' . db_helper_like( 'summary' ) .
' OR ' . db_helper_like( "$t_bug_text_table.description" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note" );
and change it with:
$t_textsearch_where_clause .= '( ' . db_helper_like( 'summary' ) .
' OR ' . db_helper_like( "$t_bug_text_table.description" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note" )
.' OR ' . "($t_bug_table.id IN ( SELECT DISTINCT bug_id from " . db_get_table( 'mantis_custom_field_string_table' ) . " where value LIKE '%$c_search%'))";
In the file core/filter_api.php search for:
$t_textsearch_where_clause .= '( ' . db_helper_like( 'summary' ) .
' OR ' . db_helper_like( "$t_bug_text_table.description" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note" );
and change it with:
$t_textsearch_where_clause .= '( ' . db_helper_like( 'summary' ) .
' OR ' . db_helper_like( "$t_bug_text_table.description" ) .
' OR ' . db_helper_like( "$t_bug_text_table.steps_to_reproduce" ) .
' OR ' . db_helper_like( "$t_bug_text_table.additional_information" ) .
' OR ' . db_helper_like( "$t_bugnote_text_table.note" )
.' OR ' . "($t_bug_table.id IN ( SELECT DISTINCT bug_id from " . db_get_table( 'mantis_custom_field_string_table' ) . " where value LIKE '%$c_search%'))";
-
bloodlessz
- Posts: 5
- Joined: 28 Sep 2012, 07:41
Re: searching in custom fields
Hi cas,
I have download the two zip files ( replace files.zip and advanced_search_function_v1.0.zip) , search for "db_helper_like" with no success.
Can you show me the steps?
What folder is the right one?
"Replace Files" or "advanced_search_function"?
When i Download the folder, i copy the file\folder under \api\soap folder?
I know, i make a lot of questions
but i don't know how to add patches to mantis bt.
Thank you
I have download the two zip files ( replace files.zip and advanced_search_function_v1.0.zip) , search for "db_helper_like" with no success.
Can you show me the steps?
What folder is the right one?
"Replace Files" or "advanced_search_function"?
When i Download the folder, i copy the file\folder under \api\soap folder?
I know, i make a lot of questions
Thank you
Re: searching in custom fields
Just make the change as described in my previous response. No need to download anything. 
-
bloodlessz
- Posts: 5
- Joined: 28 Sep 2012, 07:41
Re: searching in custom fields
Sorry,
I was looking under \api\soap\ folder on mc_filter_api.php.
Thats why i can't find these entries
It is working now
Thanks for your help
I was looking under \api\soap\ folder on mc_filter_api.php.
Thats why i can't find these entries
It is working now
Thanks for your help
Re: searching in custom fields
Thank you so much for the help!
By against if you want to just look in a custom column?
(I would add a search bar that allows you to search in a column that I have created just before)
By against if you want to just look in a custom column?
(I would add a search bar that allows you to search in a column that I have created just before)