The Search API multiple index module allows to use multiple indexes in one search. Very handy.

But currently it only seems to work for servers that support it (only SOLR I believe)

....
    if ($server->supportsFeature('search_api_multi')) {
....

Could anybody shed some light on what work would be needed to implmenent this for database search?

Comments

Anonymous’s picture

I too would love to see this extended to database server. Is this on the radar at all?

Countzero’s picture

Same here, especially since this doesn't seem to be documented anywhere.

drunken monkey’s picture

The steps for making a service class support multi-index searches are clearly documented in search_api_multi.service.inc.. The methods/changes there would have to be implemented for the SearchApiDbService class.

Hopiu’s picture

I started implementing the multi-index searches in the database server, a rudimentary version is working already. I'll post a patch when it's ready to use.

liborvanek’s picture

Any news here?

Chrummibei’s picture

We added some of the features for mutli search support and we tested them in our environment. This is by far not clearnly done or finished, but it might be used as a basis to start off from to get a clean implementation going.
I attached the patch for anyone interested.

drunken monkey’s picture

Interesting approach. I didn't consider this method at all, I always assumed that we'd have to copy the way "normal" search queries are built and slightly modify that, arriving again at a single database query.
Your approach requires much less code, is thus easier to implement and I don't think the "proper" implementation would perform that much better. In any case, it's a lot better than what we have now, which is nothing. (If it turns out this performs too badly, we can still replace it with a proper implementation later.)

One big problem I see, though, is paging/ranges. It's relatively easy with a limit and no offset: just get the first $limit items from all indexes, then merge them together (preserving the sort, of course) and cap them at $limit items.
However, once you have an offset, you'd actually have to get the first $limit + $offset items from all queries and then do the merging. (If we knew each index's total beforehand (which we could probably achieve by giving us somehow access to the count query before executing the real one), we could employ some tricks to circumvent loading all items for the last pages – but still, it could easily become a performance nightmare for larger data sets.)

Other than that, though, your patch probably needs only a little bit of work, and it would still be better then no integration at all. If we conclude it's not practical for larger data sets, we can just note that in the README.txt.

I'll look into it in the next days/week and see if I can make a completely working patch out of this. Please ping me here, someone, if I don't reply until the end of June.

And in any case, thanks a lot for posting this here, this is a great help and a really neat idea!
(I wonder, actually, if we couldn't make this a generic fallback of the Multi-Index Search module. It's hardly DB-specific, after all, and would even allow us to do multi-index queries across servers (though with horrible performance).)

drunken monkey’s picture

See #2032451: Add possibility to search indexes on any server, which would add generic support for multi-index searches to the Multi-Index Searches module itself.
If we can get that in, we should continue to use this issue for implementing the feature in the Database Search module, if we can do it better than the generic way.

drunken monkey’s picture

Could some of you please go over there and test this? Otherwise we can't get this committed. (And it's still the best chance to get support for multi-index searches on DB servers in the near future.)

webadpro’s picture

@drunken monkey, I have applied the patch from #2032451 and it applied nicely. Although, should database search just by applying that patch? Also, when creating a view with "Multi-Index Search" I get an error 500 when trying to add anything or processing the preview. Keep in mind that I do not use SOLR but DB Search only.

drunken monkey’s picture

Please report issues with that patch over in #2032451: Add possibility to search indexes on any server. But yes, multi-index searches with just the DB backend should work after applying the patch.
Have you cleared the cache after applying the patch? Then, please look into your site's log whether there are details about the error there.

realityloop’s picture

Status: Active » Needs review
StatusFileSize
new6.15 KB

Reroll

drunken monkey’s picture

Status: Needs review » Active

As said, I definitely think this patch would make more sense added to the Multi module directly, not here. So please, instead help with the patch in #2032451: Add possibility to search indexes on any server.

lsolesen’s picture

Issue summary: View changes

This seems to be already added to #2032451: Add possibility to search indexes on any server - should this issue just be closed as a won't fix then?

drunken monkey’s picture

Status: Active » Closed (won't fix)

Unless someone wants to add real multi-index-search support, yes, let's just do that. For D7, this is probably as good as it gets, and for D8 we have finally properly solved this anyways.