Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
When enabling Search API and Search API DB and you go to the configuration, you still have to select and click around. We discussed this offline and it would make sense to have sensible defaults (similar to Core Search) and some search pages based on Search API DB. Each backend can configure this for itself, and we should lead by example and do this for Search API DB.
Thoughts?
Comment | File | Size | Author |
---|---|---|---|
#30 | Screen Shot 2015-08-21 at 11.26.10.png | 60.35 KB | LKS90 |
#26 | 2470874-26--default_search_module--interdiff.txt | 4.97 KB | drunken monkey |
#26 | 2470874-26--default_search_module.patch | 28.53 KB | drunken monkey |
#23 | 2470874-23--default_search_module.patch | 28.46 KB | drunken monkey |
#20 | 2470874-20.patch | 29.02 KB | Nick_vh |
Comments
Comment #1
drunken monkeyWould this then happen completely automatically when enabling the module? Or what's the idea?
What I could imagine, when there is neither an index nor a server yet, having a button on the Search API admin overview page for creating a default setup. This could then also have simple configuration, if really necessary (multiple backends are available, or the backend cannot provide a default for some setting).
However, if we do this now it should be light-weight and self-contained enough to be easily ripped out again later if we come up with a more holistic approach to user-friendliness (i.e., #2387893: Overhaul administration UI).
Comment #2
Nick_vhVery simple patch attached that does not add any code, only configs. 1 test is failing here, so trying to figure out why.
Comment #3
Nick_vhThe idea is that this indeed happens automatically, similar to other "Extensions" and Drupal itself as well. It's easy to remove them if you do no need them. I'm not sure if there is a need for a button if there is nothing. One could import the configs from the install or reinstall the module completely if there is nothing anyway.
Shipping default configs seems light-weight to me, and easily updateable and changeable, so I don't see much risk.
Comment #5
Nick_vhreroll
Comment #6
Nick_vhComment #8
drunken monkeyAutomatically creating a server when enabling the Database Search module does make sense, yes.
However, while we initially planned to do it, it's completely impossible to have a default index or search page as configuration, as you don't know which datasources will be available. Not even the Node module is required anymore, so even doing a default node index isn't possible anymore, without code checking whether the module is there.
So, I totally agree with having a default server in the Database module, but anything else would be significantly more complex.
Comment #9
Nick_vhAt @drupaldevdays in Montpellier we discussed a couple of approaches and we settled on a submodule that depends on search_api and search_api_db and node since we will ship with sensible defaults that index your node. This should not be called example as it should be ok for sites to depend on it. the consensus initially is search_api_db_defaults.
This allows us to put plain exports in there and keep it very very lightweight. This can also serve as an example for other backend modules to ship defaults. This also allows power-users to not enable this module and start with a clean slate.
Comment #10
Nick_vhComment #11
Nick_vhWe also want some messaging in the index/server listing if you haven't enabled the module and there are no indexes or servers configured. We should help users to get started. Missing here is the view that sets up the search page for nodes and users, similar to what core search ships with.
Comment #12
Nick_vhComment #13
Nick_vhI'm being stupid. Going to add the views now
Comment #14
drunken monkeyLooks good so far, thanks!
The view is of course still missing (the module should then just also depend on Views, though), also I saw these little issues:
Default config should never have UUIDs, as far as I now.
Is 1 really the best default here? I think 3 will usually make more sense.
We do already have that on the Tokenizer, though, so it should probably not matter much (except for numeric tokens, I think?).
Maybe link that to the Modules page?
Comment #15
Nick_vhRegarding 2, we should revise our defaults then as I did not adjust that value manually
Comment #16
drunken monkeyHm, yes, I guess that would make sense. Using "1" as the default seemed the most natural selection, since all others are more arbitrary choices, but I guess having a sensible default (at least for English) is still better.
Comment #17
Nick_vhThis time with views. Relies on the #2471669: Views should show the view mode for each bundle as view modes are configured per bundle patch
Comment #18
drunken monkeyComment #19
Nick_vh@todo : Create simple test that installs this module and checks if
* the views page is there.
* the view modes are there
* the index is there
* the server is there
Comment #20
Nick_vhAdded those tests and also attached is an interdiff
Comment #21
Nick_vhduh - not an anonymous user if we create a user object. This should be renamed to authenticatedUser and we should test with anonymous and with authenticated to see if the view is accessible to both.
perhaps change types to bundles?
Comment #22
Nick_vhAdditionally, I was curious why the view initially exported with views_query as the query plugin for the view instead of with search_api_query. This caused the view unable to import as config to the system and the worst part was that it doesn't show any error. This might even be a drupal core bug, needs further investigation and steps to reproduce.
Comment #23
drunken monkeySorry for the long delay, was very busy unfortunately.
The patch looks already very good, but needed a re-roll. I also found these problems:
See #2473757: Only sentences should end with periods.
Why include that? I don't think that should ever be in the options, we only use that key for display purposes when editing the server.
If this results in a value saved in the options, it's definitely a bug (even sounds like one in Core?), and in any case nothing we should replicate in our default configuration.
Regarding your own two remarks in #21: do you want to still implement them here, or should I commit and we'll make a follow-up?
Anyways, patch attached. Set to "Needs work", though, because before #2473717: Add support for per-bundle view modes in the rendered entity processor gets fixed again it will fail anyways.
Comment #24
drunken monkeyComment #26
drunken monkeyOK, I just implemented your two suggestions. As I did, I noticed I hadn't reviewed the new test class before. So I also made these changes:
The first sentence of a doc block should always be on its own line and never exceed 80 characters (including the
*
preceding it).Also, methods should almost never be
private
.Since each test method means a complete site install, for performance reason I always try to stick with a single test method (aside from PHPUnit tests).
Copying bad code from Core is no excuse to skip the
@return
tag. ;PThe attached patch is RTBC for me. If the test bot agrees and no-one objects, I'll commit it.
Comment #27
drunken monkeyWow, that was quick! The test bot speed on weekends is insane …
So, since the test bot is happy: committed.
Thanks a lot again, Nick!
(If someone wants to object after all, please re-open!)
Comment #30
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedWith this patch the
search_api.index.default_index.yml
was committed which is currently not correct and makes the search_api_db_defaults useless.Here is a screenshot of the database, tables and fields which this config produces on a fresh install:
Every field after the entity:node/title one is missing, which causes errors when indexing as it tries to insert values into a non-existent column.
Here is the issue I created a while back when I initially noticed the issue: #2510564: Indexing is broken
We can probably fix the config in that issue.
Comment #31
drunken monkeyIf there is already an issue, why did you re-open this one?
Comment #32
LKS90 CreditAttribution: LKS90 at MD Systems GmbH commentedSorry, will do the work in the other issue and close this one.
Comment #33
tim.plunkett