Closed (fixed)
Project:
Search API Autocomplete
Version:
8.x-1.x-dev
Component:
Code
Priority:
Normal
Category:
Task
Assigned:
Unassigned
Reporter:
Created:
7 Mar 2016 at 22:14 UTC
Updated:
30 May 2017 at 10:05 UTC
Jump to comment: Most recent, Most recent file
Comments
Comment #2
drunken monkeyIt's definitely planned, yes, but might still take a while. The first priority is to get a stable release of Search API itself, then I'll probably tackle the add-on modules according to their usage numbers. Or according to funding, if someone is interested enough in a port.
Comment #3
luo8 commentedHello drunken monkey,
ok...thanks a lot
Comment #4
geerlingguy commentedI created a contrib tracker issue so the status can be more easily tracked via the project page: #2700691: [search_api_autocomplete] Search API Autocomplete
Comment #5
dawehnerI'm looking into porting the module now: https://github.com/dawehner/search_api_autocomplete
Comment #6
dawehnerQuick startup report:
* You can create autocomplete configurations using the UI, both for views and page searches
* Autocompletion is provided for both the views and page searches
* A lot of things could be cleaned up still, of course
* The autocompletion of views act a bit weird, it seems to show too many results. Should be investigates
This is certainly in a state where testing/feedback would be highly appreciated.
Comment #7
mpp commentedGreat! I'd be willing to test this out. Could you create a branch on d.o for 8.x?
Comment #8
dawehnerHere is a patch relative to 7.x-1.x, but of course, I cannot create a branch against 8.x-1.x, because I'm not a maintainer or so.
Comment #9
drunken monkeyAwesome work so far, thanks a lot!
I haven't tried it yet, but I've added the branch to the d.o project (along with one commit from me cleaning up a lot of small stuff) and done a review. Here is what I found and would still like to be fixed before creating an initial Alpha release:
AutocompleteTypeInterface::listSearches()in favor of that?I guess determining the autocomplete type plugin for those displays would then be a nissue, though. We actually did some thinking regarding letting display plugins support features, too, but that would again move the code away from this module and to the Search API and Pages modules – not what we want, I think. (Especially since the Search API maintainer is pretty strict about adding third-party integration code to the framework.)
I would solve the problem of having to pick one display for all searches based on a view, by just creating one search config entity per display, not per view. (You can do that in any case, though – and might be a good idea, too. See #2711635: support multiple view displays for autocomplete.)
AutocompleteTypeInterface::listSearches()isn't static.However, I think using derivers to create one plugin per view (or display) and per page would be cleaner in any case.
I'd find it helpful, because easier to navigate, if this module kept to the same structure. Or am I mistaken and the majority of Core uses a different standard?
In any case, I think it's a good idea to add
@seetags referencing the other three framework classes of the plugin type to each of the class description (so, not to theServerplugin in this example, but to all other classes).Using
Suggesteras the common prefix, notAutocompleteSuggesterwould be my personal preference here, but I'm not really against using the longer version either.delayconfig setting, and maybe evenscripts, too, should just become settings on the individual search entities, not hidden config values. But that can happen in a separate issue just as well.Drupal.jsACnorDrupal.ACDBseem to exist anymore in Core, so overriding them will either not do anything or even produce errors.ConfigurablePluginInterfaceis not part ofAutocompleteSuggesterInterface?\Drupal::or function calls wherever possible.REAMDE.txt. However, it seemssearch_api_autocomplete.api.phpstill needs a complete overhaul.If you'd be up to continuing work on this, you can either still continue in your Github branch or start working with patches here – your choice.
In any case, thanks a lot again!
Comment #10
drunken monkeyComment #11
dawehner@drunken monkey
Thank you for that great feedback. I'll try to create issues for the individual bits. It seems to be that you created a branch, but without pushing anything. I assume this was on purpose?
Comment #12
dawehnerComment #13
dawehnerComment #14
dawehnerSome continues work on a couple of the excellent review points.
Comment #15
dawehnerSure, there is no reason, let's quickly fix that.
Comment #16
dawehnerThe check at the beginning of the file:
if (typeof Drupal.jsAC != 'undefined') {ensures we don't have any fatal. This file needs a complete rewrite as Drupal core now uses Jquery UI autocompletion instead of its own autocompletion, which is great!Here is some more work, renaming a couple of classes/interfaces.
Comment #17
drunken monkeyThanks a lot for your continued work on this!
I did, I pushed everything from your Github branch. Was there more in the patch?
In any case, it seems you're now not using the Github project anymore – but your patches also don't apply on the current dev version. Could you please either provide one or more patches against the current branch contents (d.o or Github – they're identical), or keep using your Github branch?
I therefore also couldn't review your latest changes, but I'll look at them later.
Comment #18
drunken monkeyOoops, cross-posted with myself.
Comment #19
dawehnerOh damnit, I pulled from my remote by accident and by that I haven't seen your changes. No worries, I'll create a interdiff now and continue to work on the github branch.
Comment #20
dawehnerResolved that.
I also moved some of the functionality out of the entity object, because, IMHO, those entity objects shouldn't contain too much logic, if possible.
On top of that I tried to have a look at the autocompletion JS changes. Its not obvious how we could alter the autocomplete object initialized by the core autocompletion object. Maybe we need to ship with our own JS file.
Comment #21
dawehnerHaha, that's kinda nice!
Comment #23
drunken monkeyCommitted those last two patches, thanks once again!
Are you now finished with this, at least as far as you're concerned, or is there still work to do? Since the changes are massive again, I think just reviewing the whole module once more when you're done (and when I have the time) makes more sense. (I'll also create an Alpha release, once you say it's usable.)
One thing I did already notice, though, is that you're using short array syntax. Which is great, and fine by me, but please also change the last few places where the old syntax is used (easy to find with
git grep 'array(') to keep this consistent within the module. (In the Search API, we regrettable went with keeping this consistently the old syntax. :-/)Comment #24
dawehnerThank you for your commit!
I have a bit of a time problem at the moment, so I'm not sure when I'll be next be able to look into it, but honestly, I haven't done manual testing since milano, so potentially some of the refactoring caused issues.
Fair point :)
I hope I'll find time in the time again to push it a bit more forward.
In case you have more review points, please point them here. The more they are, the more likely I will just work on a block of them :)
Comment #25
dawehnerI pushed a couple of more commits today, see https://github.com/dawehner/search_api_autocomplete/commits/8.x-1.x
Comment #26
borisson_This should be SearchApiAutocompleteSearch[], I guess?
Should be only one blank line.
2 small suggestions, but the rest looks great.
Comment #27
dawehnerComment #28
borisson_Woo!
Comment #29
andypostCan we get #27 in?
Comment #31
drunken monkeyThanks a lot! Committed.
However, does
hook_default_search_api_autocomplete_search()even still work? That was a hook provided by the Entity API to define default entities. With D8's config framework, I don't think it exists anymore.Same thing for
hook_search_api_autocomplete_types()and all theexample_*()functions referenced there – now that autocomplete types are plugins, none of that applies anymore, right?You can remove the entity hooks, too – they're all already documented as
hook_ENTITY_TYPE_*()by Core.So, really, I think only these three hooks need to be in there (as far as I can see):
- hook_search_api_autocomplete_suggestions_alter()
- hook_search_api_autocomplete_suggester_alter()
- hook_search_api_autocomplete_type_alter()
We always assume no cacheability of any search data, and I don't think that will change (at least in the near future). So just set max-age to 0.
Comment #32
borisson_You can use UncacheableDependencyTrait to make that easy to implement.
Comment #33
dawehnerThank you for committing the current progress.
OH yeah, as written before, this documentation is totally outdated and doesn't work at all.
That's a good list, thank you!
Comment #34
borisson_Should we close this issue and continue on in issues per todo from here?
Comment #35
dawehnerI'd totally say +1 for that.
Comment #36
borisson_I added #2865821: Add, test and document alter hooks, not sure if there are other todo's we can open already.
Comment #37
drunken monkeyI've added #2877645: Overhaul "type" plugin system and #2877648: Review/port our Javascript overrides as further follow-ups.
In other news, I'm now starting work on this, so will probably/hopefully soon post a patch with a first overhaul of the module. I'd say we can close this issue after that and continue in separate issues for further tasks.
Comment #38
drunken monkeyHere is a general overhaul of the module regarding code style, class names/structure, etc.
Would be great to get some tests or reviews. I fear the upgrade won't be completely painless, though, since some of the entity properties have changed. (The changes in service IDs and class names, on the other hand, should be resolved with a simple cache clear.) But that can't be helped, and must be expected of a module in Alpha phase.
Comment #40
drunken monkeyAh, I also forgot to actually change the current code using
optionsto usesuggester_settingsandtype_settingsinstead, as appropriate.Comment #41
drunken monkeyThis should fix both the test failure and the plugin configurations (for the most part).
Comment #42
drunken monkeyComment #44
drunken monkeyThird time's the charm?
Comment #45
borisson_Not sure if 'results' is the best here, is 'show_count' better? I think it more clearly describes what the option does.
The formatting here looks kinds of wonky, can we change this?
I think we'd benefit from doing something like:
Needs, at least a one-line description.
Comment #46
borisson_The patch is really big, so a comprehensive review is not so easy to do, but these are the things that stood out. Overall this looks good though.
Comment #47
drunken monkeyThanks for the review, and your great suggestions! Should all be implemented in the attached patch.
And yes, I know it's not easy to review. I'd just hoped I'd get a few people to just test whether it breaks anything for them, then commit and hope to come across all parts of the code again in separate issues in the future so we can spot any remaining issues, or bad decisions during this initial overhaul.
In other words: It doesn't have to be perfect right away, and it's OK if not even all of the changes here make sense. (I'd just like to avoid breaking anything that already works.)
Comment #48
drunken monkeyAnd one more thing …
Comment #49
benjy commentedI tested the page has got the following error, renaming the type-hint to Search made everything work as expected.
Comment #51
drunken monkeyThanks a lot for testing, good to hear!
For adapting the Solr module accordingly, see the appropriate patch in #38, or #2878601: Adapt to changes in Autocomplete module.
Anyways, as this seems to work well enough, I've now committed this so work can go on in the other issues. If we broke or missed something, we can always fix it later.
Thanks again to everyone here – especially to dawehner, of course!