1) If the index is defined in code, it doesn't find any nodes (says 0). Once I edit it and it gets saved to the DB, the node count appears.
2) When exporting an index, it looses the checkboxes of which fields are indexed. The others stay.
3) A number field indexed as decimal. If there is no value for the field (or maybe a node without the field at all?), indexing in solr fails and in the log there is a java exception (numberformatexception) empty string no valid number.
4) Include "missing" facet option in the block configuration does not save. Should be off by default too?
5) Fulltext: Whether field should be indexed in the fulltext is something different than how it should be indexed at all. Eg. we want to index term-names as "string", but have it in the fulltext too. Ergo, I think fulltext should be a separate checkbox.

Some suggestions:
6) When editing the full text views filter: "Search keys – multiple words will be split and the filter will influence relevance. " should be enabled by default I guess.
7) Some direct links to the index tab in the overview UI would be nice. lots of clicks necessary.... ;)
8) Index just the entity view as fulltext.

Support from Acquia helps fund testing for Drupal Acquia logo

Comments

drunken monkey’s picture

Title: some random bugs I ran over » Some random bugs
Status: Active » Needs review
FileSize
3.64 KB

1) If the index is defined in code, it doesn't find any nodes (says 0). Once I edit it and it gets saved to the DB, the node count appears.
2) When exporting an index, it looses the checkboxes of which fields are indexed. The others stay.

As you may have noticed by now, I really have no clue about exporting. The first one sounds like what we talked in the other issue about, $entity->save() being called when an entity is newly added in code. Could that be it? What could be wrong for 2)?
And how do I even test exporting the best way?

3) A number field indexed as decimal. If there is no value for the field (or maybe a node without the field at all?), indexing in solr fails and in the log there is a java exception (numberformatexception) empty string no valid number.

Does the attached patch fix this (and other issues here)?

4) Include "missing" facet option in the block configuration does not save. Should be off by default too?

If it had just been that! On testing this (and looking at the code), I noticed, that not a single custom block option is saved, I completely forgot the necessary code. Yeah … …
But the attached patch should fix this, too, thanks for spotting it!

5) Fulltext: Whether field should be indexed in the fulltext is something different than how it should be indexed at all. Eg. we want to index term-names as "string", but have it in the fulltext too. Ergo, I think fulltext should be a separate checkbox.

As I already said, I'm gonna redo the "Fulltext field" data-alter callback anyways, to no longer use this admittedly ugly behaviour. So this should then be obsolete, if I understand this correctly.

6) When editing the full text views filter: "Search keys – multiple words will be split and the filter will influence relevance. " should be enabled by default I guess.

You're right, that bothered me, too … And now that I have an issue to link to (;)): done, in patch.

7) Some direct links to the index tab in the overview UI would be nice. lots of clicks necessary.... ;)

Same as above – but I don't really know how to do this. Adding all tabs in the "Operations" column probably won't fit – and also, servers would look odd, then.

8) Index just the entity view as fulltext.

What do you mean?

fago’s picture

ad export:
Looking at search_api_entity_update() the problem is that it directly queries the db instead of using entity_load() for getting indexes.

Additionally I think the current approach of initializing 'search_api_item' once the index has been created (on 'insert') doesn't work for exported entities, as hook insert is not called on a system with an index living in code. It get's only called if someone overrides the entity later on.
Indeed, the lifecycle of configuration items isn't ideal yet and needs to be improved in order to for use-cases like yours being possible cleanly. As interim workaround I'd suggest to implement hook_modules_enabled() + determine whether the module provides default configuration for you + if so, initialize it.

ad 2)
Sry, it must have been my fault. Somehow, now it's working fine.. :)

ad 7)
I'd suggest just adding in all tabs in the operations column. It might not look too nice, but at least its nicely usable then.

ad 8) I meant just indexing the output of $entity->view() and using this as fulltext - as discussed. Probably out of scope for this issue ;) But anyway, with 5) we currently don't have a way to do a fulltext search involving the rather important term names as we need to index them as strings. So it'd be nice to have either 5) or 8) fixed soon, so a proper fulltext search is doable.

@others: going to give the patch a test now.

fago’s picture

ok, tested it

ad 4) saving works now, also the default is good. But the logic seems to apply inverted. If the checkbox is not checked, the "none" value appears.

New stuff I previously forgot / did not notice:
9) The options list is not taken into account for a facet - it displays the keys. Tested with a list of numeric values indexed as strings.

10) Hm, now the facet block for the term-names (indexed as string) is gone. It won't appear although it has values. The facet block for the decimal field indexed as string is still here.

ad 3)
The bug is still here. However it's a bit strange. I tracked it down to happen on empty term-names. It get's the following the key 'sm_field_of_study:name' and is indexed as 'string'. However still the error is the number format exception.

However, what is a bit strange is - that it happens only if I have a node in the system which either has not the *decimal field* - thus another field - at all or the field is empty.

fago’s picture

also I wonder about


    switch ($type) {
      case 'tokens':
        foreach ($value as $v) {

in solr's service addIndexField() method. Shouldn't the type be 'token'? at least in entity metadata it is.

fago’s picture

ad 3)
no, it's working now. There was a bug in entity metadata, once I fixed that (http://drupal.org/cvs?commit=446444) it works. I don't know why the exception was thrown delayed (when already another field was processed), but anyway - it's working now.. ;)

So the problems described above regarding 4) (as well as 9)) remain + the patch introduces 10).

drunken monkey’s picture

Additionally I think the current approach of initializing 'search_api_item' once the index has been created (on 'insert') doesn't work for exported entities, as hook insert is not called on a system with an index living in code. It get's only called if someone overrides the entity later on.
Indeed, the lifecycle of configuration items isn't ideal yet and needs to be improved in order to for use-cases like yours being possible cleanly. As interim workaround I'd suggest to implement hook_modules_enabled() + determine whether the module provides default configuration for you + if so, initialize it.

That's why I asked in #939482-16: Fix exportables whether save() is called for entities in code – if it isn't, this is indeed a problem … Is there really no other way than this ugly hack, then? And how does a module provide default configuration?
But of course you are right about search_api_entity_update(), missed the direct db query there (and in search_api_entity_insert()).

Regarding the others: Working on it. "tokens" is correct, though, it is a custom type introduced by me (for tokenized fulltext), before you introduced "token". I don't use "token" at all, since it's called "string" in the Search API.

fago’s picture

>That's why I asked in #939482-16: Fix exportables whether save() is called for entities in code – if it isn't, this is indeed a problem … Is there really no other way than this ugly hack, then? And how does a module provide default configuration?

No, it isn't. I think there is a better way to solve this - by providing some additional hooks. I'll work on that asap, but for now I think the mentioned workaround is the best we can do.

>And how do I even test exporting the best way?
Best, install features and use it to generate feature modules including search api configuration. The entity API makes the search API stuff available to features for you.

drunken monkey’s picture

FileSize
7.36 KB

OK, I've lost track a bit, hope I don't forget anything …

ad 1) OK, then I'll try to implement that hack … But first a patch for most other bugs here, if it's OK I'll commit it and then work on 1).

ad 4) Works for me, no idea what's wrong on your side. The attached patch contains a cosmetic change in the logic, but behaviour is identically correct both before and after the patch, for me.

ad 7) Those would a) be really many (6 or 7 links?) and b) there wouldn't be a clean way to add the "Facets" tab as well.
As an alternative I tried adding contextual links, but after some ugly code-crawling I discovered that the module is, in its current state, obviously not fit to be used by anything other than core. Ugliest hardcoded stuff, there …
But what about implementing a similar thing myself? Shouldn't be too hard – then there still would only be three links, but with Javascript enabled, a click on "edit" would open a selection with all tabs (other than "view", of course).

ad 9) As I told you, it should be taken into account (e.g. for user roles it works), it apparently just doesn't work in all cases. I now discovered that this is caused by two seperate bugs – one in my module (not adding the index' property info alter method, therefore fields on bundles weren't even found) and one in yours: #963218: Options list for multi-values custom fields behaves oddly. My bug is fixed in the attached patch – your turn. ;P

ad 10) OK, this is a bit of a mess, there are several issues here. First, I think I didn't clear the block cache quite correctly, previously. I also only now added a check when viewing a facet, that it is enabled, before proceeding. But still, this only hides the underlying bug in the block module – because, even though the block isn't displayed on the block adminstration page, I cleared the cache, and whatnot, the block is still displayed (without my $facet->enabled check, that is). And that can't be right. (At least since I specified DRUPAL_NO_CACHE as the caching strategy.)

fago’s picture

thanks, tested it.

4) strangely, now the logic is ok. However I noted this influences 10)

The problem with 10) is: If I not check the "show missing in facets" option, then the block doesn't appear at all. However, once I enabled the checkboxes the facet blocks appeared - with one exception. The second facet block for taxonomy terms is still not showing up, regardless what I configure for it. Perhaps there is bug involved so that the second facet block for the same type is not working?

Summary:
Currently I have the facet block for a decimal field + one for a term reference (multiple) working. The second term reference facet block is still missing.

fago’s picture

oh, and if I clear the cache get those:

    * Notice: Undefined index: name in block_menu() (line 147 of /var/www/fago/web/recruiter/modules/block/block.module).
    * Notice: Undefined index: name in block_menu() (line 166 of /var/www/fago/web/recruiter/modules/block/block.module).
    * Notice: Undefined index: name in system_menu() (line 638 of /var/www/fago/web/recruiter/modules/system/system.module).
drunken monkey’s picture

Status: Needs review » Needs work

Sorry, I still can't reproduce this. I now have three facet blocks for term fields, two on the same field and one on another, and I still can't do anything to make this not work. I even discovered a Field UI bug in the progress …

I now committed the patch so far, but as said will continue work on 1), and 9) is up to you. For 10) you could provide more detailled steps, but possibly you'll have to debug it yourself, when I can't reproduce the bug and have no other clues. That the two blocks have the same type shouldn't matter at all. And just searching through the whole module for any bug would be a bit tedious …
You could e.g. look if the facet is saved correctly, what search is executed and if the results are correct (especially, of course, the "search_api_facets" component).

oh, and if I clear the cache get those:

    * Notice: Undefined index: name in block_menu() (line 147 of /var/www/fago/web/recruiter/modules/block/block.module).
    * Notice: Undefined index: name in block_menu() (line 166 of /var/www/fago/web/recruiter/modules/block/block.module).
    * Notice: Undefined index: name in system_menu() (line 638 of /var/www/fago/web/recruiter/modules/system/system.module).

This seems to mean that you have a theme installed that doesn't define a name, looking at those code lines. I highly doubt that this has anything to do with this module.

fago’s picture

>This seems to mean that you have a theme installed that doesn't define a name, looking at those code lines. I highly doubt that this has anything to do with this module.

hm, I never got those before I started playing with the facet blocks. Well, but maybe the block stuff got mixed up in the meantime on the site. I'll try this and the facets on a fresh install and report back.

drunken monkey’s picture

Status: Needs work » Needs review
FileSize
7.5 KB

The attached patch solves (at least it seems like it, according to my tests) a good amount of 1).
A mechanism for detecting changed hook_default_search_api_index() implementations is missing (and not possible in this way), though – people would have to disable and re-enable the feature module for this to work. A solution from the Entity API would be nice, therefore.

I'm gonna try the JS-edit-menu thing now …

drunken monkey’s picture

FileSize
13.55 KB

And this one also incorporates a nice (well, at least not too shabby) edit menu for getting directly to individual tabs (even "Facets") from the overview.

Oh, and both patches contain a fix for most of the duplicate hook invocations (search_api_[server/index]_[insert/update/delete]()).

fago’s picture

Status: Needs review » Reviewed & tested by the community

>I'll try this and the facets on a fresh install and report back.

Indeed, on a fresh install its working. Great :)

ad #13: tested it, works! Agreed, we need to solve this generically in the entity API, I already have some thoughts on that. Will post a RFC soon.

ad #14: ad edit menu - yep that's nice. that's already much better to use :)

>Oh, and both patches contain a fix for most of the duplicate hook invocations (search_api_[server/index]_[insert/update/delete]()).

hm, still for $op != 'edit' both hooks are invoked? I'll guess the only way to fix this and to keep $op is overridding the controllers invoke + save methods... so that's still open, but no cause to halt this patch.

drunken monkey’s picture

Status: Reviewed & tested by the community » Fixed

hm, still for $op != 'edit' both hooks are invoked? I'll guess the only way to fix this and to keep $op is overridding the controllers invoke + save methods... so that's still open, but no cause to halt this patch.

Yes, you're right, I'll have to fix that at some point. Went for the "quick-and-dirty" fix for now … Therefore, new issue: #964816: Provide own EntityController for fixing hook invocations.
Anyways, committed, thanks for reviewing (and finding the bugs to begin with)!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.