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
Comment | File | Size | Author |
---|---|---|---|
#19 | 2513126-19--expose_views_fulltext_fields--interdiff.txt | 4.29 KB | drunken monkey |
#19 | 2513126-19--expose_views_fulltext_fields.patch | 4.71 KB | drunken monkey |
Comments
Comment #1
anksy CreditAttribution: anksy commentedI 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.
Comment #2
anksy CreditAttribution: anksy commentedComment #3
anksy CreditAttribution: anksy commentedHere 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"
Comment #4
anksy CreditAttribution: anksy commentedThere 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?
Comment #5
anksy CreditAttribution: anksy commentedComment #6
anksy CreditAttribution: anksy commentedHere 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.
Comment #7
anksy CreditAttribution: anksy commentedComment #9
japerrySo 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.
Comment #10
japerryHere 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
Comment #11
japerryInterdiff for above patch. which should be #10 instead of 11 but oh well.
Comment #12
anksy CreditAttribution: anksy commented@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.
Comment #13
japerryPatch 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.
Comment #14
anksy CreditAttribution: anksy commentedYeah, I also meant to remove that in my last patch. It was a mistake. Rectified it in this patch.
Comment #15
japerryHere specifically is the problem with the title search showing up within the submit button.
Comment #16
drummI also see a few whitespace problems:
'edit-options-expose-use-fields' => array(1)
needs a trailing comma.And there is some debug code,
dpm($use_fields);
.Comment #17
anksy CreditAttribution: anksy commentedSolved the issues suggested by drumm.
Comment #18
anksy CreditAttribution: anksy commentedSolved the issues suggested by drumm.
Comment #19
drunken monkeyThanks a lot for the patch, seems to work fine!
The coding style was still a bit off, but that should all be fixed in the attached patch.
If that one's OK for everyone else, too, I'll commit it in the next few days.
Comment #20
japerryDrunken 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!
Comment #21
japerryThe issue in comment 15, relating to the search criteria being placed within the submit button, has still not been fixed yet.
Comment #22
legolasboThis 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.