Problem/Motivation

It should be possible to limit the search through the issue queue to the title field. Currently it is a full text search which often yields to many results.

Also, searching for meta issues would be possible if search could be restricted to words in the title. This project is a part of GSoC 2015. This issue is related to the following issue #2226335: Add checkbox to limit issue search to title on d.o.

This issue specifically pertains to improving the search api by adding a feature. The other issue pertains to adding the feature to d.o.

Here is the development site built for this issue: https://issue-search-title-drupal.redesign.devdrupal.org
Username/Password for accessing the site is drupal/drupal

Remaining tasks

  • Add the checkbox filter to the query - Done

Steps to reproduce

  • Install a drupal 7 site
  • Add and enable the following modules
    • Search api
    • Views
    • Search api database
  • Create some example content using the devel module
  • Create a view
  • Index all the content in the search api index
  • Create some fields in the view that are indexed like title,body,comments.
  • Add a fulltext search filter in the filters tab of the view
  • Apply the patch
  • In the configure fulltext search view you will get an option of exposing the use_fields filter.
  • Enable it
  • In the view page you will see a select menu with the fields that you want to search in

User interface changes

Issue_search_UI

Issue_search_UI2

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

anksy’s picture

I have been working on this issue and to implement the filtering of the query we have to use the query method of the handler_filter_fulltext.inc. I have implemeted the filter on the filter config form and also in the issue search form.
Now the work that is remaining is to link both to the query.

I have looked at the query that is generated using the "Search for" filter in handler_filter_fulltext.inc inside the method query().
I will extend that method to also include the title search filter.
For that I need to know where is the value of the filter that the user selects is stored. In other words, which variable contains the input entered by the user?

The attached patch contains the code that I have written till now.

anksy’s picture

Issue summary: View changes
anksy’s picture

Here is a patch with the filter for the project search api.
Here are the before and after test case screenshots.

Initial view of the filter

When searched without the "Searched fields filter"

View with the "Searched fields filter"

anksy’s picture

Status: Active » Needs review
FileSize
68.07 KB

There is a problem with the UI. When you search for a term on the issue search page it starts showing two select boxes. Below is the image of the problem.

I think this issue is because the function that makes this select box in handler_filter_fulltext.inc is called twice.
Can anyone comment on how to solve this problem?

anksy’s picture

Title: Add checkbox to limit issue search to different fields like the title, comments etc. for drupal.org » Add checkbox to limit issue search to different fields like the title, comments etc. in search api
Issue summary: View changes
anksy’s picture

Here I have added the fields_id field into the filter config form and to the url of the issue search form. I have solved the duplicacy issue and completed the addition of a fields_id field.

anksy’s picture

Status: Needs review » Needs work

The last submitted patch, 7: add_checkbox_to_limit_on_do-2513126-7.patch, failed testing.

japerry’s picture

Status: Needs work » Needs review
FileSize
7.26 KB

So there are a few issues with the patch in #7, outlined below.

1) Wrong file path for the patch, it should be applied to the git HEAD of searchapi. This is why its partially failing tests, since it doesn't apply. However drupalorg uses a much earlier git hash, which will require testing if we are to upgrade search_api on drupal.org.

Edit: rest of comments don't apply.
Here is a patch that should fix most of these issues. While it is applied against git hash debf49e3d88277bdb19acb12832d4abdbd1ba4ef -- it appears to not cause conflict to HEAD either. So it should work as a patch without needing to update search api itself on d.o.

Working next to merge in Anksy's patch with mine.

japerry’s picture

Here is another roll that makes it possible to view all titles. Both this one, #9, and #7 have an issue where they're being rendered within the submit button.

However, I don't think we need the init or $_SESSION functions that the operator function was using. So those are removed. I've also removed hardcoded values from #7 and moved them into another patch for drupal.org #2226335: Add checkbox to limit issue search to title on d.o

japerry’s picture

FileSize
1.51 KB

Interdiff for above patch. which should be #10 instead of 11 but oh well.

anksy’s picture

@japerry We need a select menu instead of a dropdown. So instead of modifying the patch that you posted I incorporated almost all the changes that you suggested in my patch and now I am posting it with the modifications that you suggested. I have just not incorporated the change that you suggested in the query method as I can't remove it without changing significant amount of code.

japerry’s picture

Status: Needs review » Needs work

Patch has hardcoded values for search values, please refer to #2226335: Add checkbox to limit issue search to title on d.o where we need to make those specific changes.

anksy’s picture

Yeah, I also meant to remove that in my last patch. It was a mistake. Rectified it in this patch.

japerry’s picture

Here specifically is the problem with the title search showing up within the submit button.

drumm’s picture

I also see a few whitespace problems:

  • SearchApiViewsHandlerFilterFulltext::init() needs a blank line after the method.
  • SearchApiViewsHandlerFilterFulltext::expose_form() has incorrect indentation.
  • 'edit-options-expose-use-fields' => array(1) needs a trailing comma.

And there is some debug code, dpm($use_fields);.

anksy’s picture

Solved the issues suggested by drumm.

anksy’s picture

Status: Needs work » Needs review

Solved the issues suggested by drumm.

drunken monkey’s picture

japerry’s picture

Drunken monkey, im on vacation this week and would like a chance to test this patch. If it can wait until next tuesday (8th) or Wednesday (9th), that'd be much appreciated!

japerry’s picture

Status: Needs review » Needs work

The issue in comment 15, relating to the search criteria being placed within the submit button, has still not been fixed yet.

legolasbo’s picture

Status: Needs work » Closed (outdated)

This issue has not seen activity in over 2,5 years. I am therefore closing this issue to clean up the issue queue. Feel free to re-open and update this issue if you feel this issue is still relevant and of importance.