Quicksearch problems revisited - ca_storage_locations.is_enabled
Once a long time ago....I was working to try to figure out why quicksearch vs normal search were not returning storage locations. After many trials with search indexing, etc I have found the problem to be that:
ca_storage_locations.is_enabled is NOT defined, so it will always fail in QuickSearchController.php
ca_storage_locations.Is_enabled IS defined.
changing:
return $o_storage_location_search->search(($ps_search == '*') ? '(ca_storage_locations.is_enabled:1)' : '('.$ps_search.') AND (ca_storage_locations.is_enabled:1)', $search_opts);
to
return $o_storage_location_search->search(($ps_search == '*') ? '(ca_storage_locations.Is_enabled:1)' : '('.$ps_search.') AND (ca_storage_locations.Is_enabled:1)', $search_opts);
If I change ca_storage_locations.is_enabled to ca_storage_locations.Is_enabled then it works just fine.
I do not see any place where Is_enabled is defined. /app/models/ca_storage_locations.php has it as 'is_enabled', the ca_storage_locations mysql table has it as 'is_enabled', search_index.conf has it as 'is_enabled'
Any idea? I am so close to solving this!
Thanks
Bruce
Comments
almost forgot:
It works on my test systems and the demo as-is. Did you change anything in your configuration or code?
not that I know of. This has been a long evolving database, so errors could have crept in over time and revisions.
I do have use a custom profile, but that's mostly for print templates.
I just dont see where Is_enabled is mentioned anywhere within a file. Unless there is something within the database that could redefine is_enabled to Is_enabled. Localization?
Might this be a MySQL thing? I see 'lower case file system' is set to OFF, and 'lower case table name' is set to 0.
The demo works with both .is_enabled and .Is_enabled. My system ONLY works with .Is_enabled.
Where is 'lower case file system' set? Can you do a DESC on the ca_storage_locations table in your system and post the output. Eg. in MySQL run this query:
DESC ca_storage_locations;
They are displayed (I cant change them) in the Variables tab of the mySQL server in mysqladmin.
Field Type Null Key Default Extra
location_id int(10) unsigned NO PRI NULL auto_increment
parent_id int(10) unsigned YES MUL NULL
type_id int(10) unsigned YES MUL NULL
idno varchar(255) NO MUL NULL
idno_sort varchar(255) NO MUL NULL
is_template tinyint(3) unsigned NO 0
source_id int(10) unsigned YES MUL NULL
source_info longtext NO NULL
color char(6) YES NULL
icon longblob NO NULL
hier_left decimal(30,20) NO MUL NULL
hier_right decimal(30,20) NO MUL NULL
access tinyint(3) unsigned NO 0
status tinyint(3) unsigned NO 0
deleted tinyint(3) unsigned NO 0
rank int(10) unsigned NO 0
is_enabled tinyint(3) unsigned NO 1
view_count int(10) unsigned NO 0
submission_user_id int(10) unsigned YES MUL NULL
submission_group_id int(10) unsigned YES MUL NULL
submission_status_id int(10) unsigned YES MUL NULL
submission_via_form varchar(100) YES MUL NULL
submission_session_id int(10) unsigned YES MUL NULL
idno_sort_num bigint(20) unsigned NO MUL 0
Revisiting this problem that seemed to go away for a bit...but is back.
So if I search for a storage location:
/ca/index.php/find/SearchStorageLocations/Index
with
* AND (ca_storage_locations.is_enabled:*)
it returns ALL locations.
if I search for
* AND (ca_storage_locations.is_enabled:1)
it ONLY returns NEWLY CREATED LOCATIONS.
Once I reindex it will return NOTHING.
This happens even if I remove my local search_index.conf
Once again, running git/developed......just pulled this morning.
Any idea?
Problem Mostly Solved!
It seems like (within /app/lib/Search/SearchIndexer.php ~line 252) will fail reindexing if there are less than 500 storage locations:
if (!($vn_i % 500)) { // Pre-load attribute values for next 500 items to index; improves index performance
$va_id_slice = array_slice($va_ids, $vn_i, 500);
My "solution" is to change the 500 to 2:
if (!($vn_i % 2)) { // Pre-load attribute values for next 500 items to index; improves index performance
$va_id_slice = array_slice($va_ids, $vn_i, 2);
Any thoughts?
Thanks
That really fixes your problem? That code just loads intrinsic values in bunches to improve performance. The data is pulled every 500 rows starting with the first row.
I just tried reindexing the demo, which has 12 storage locations. They're all searchable as they should be.
If your mod works for you go for it, but so far I can't see the problem.
ok, feeling a little foolish - so this mod worked because i had some old debugging code that was popping the first element of the array off so that any count under 500 was always failing. It was a new problem i created.
the real fix was a missing comma in app.conf. Also a foolish mistake, but very hard detect sometimes.
which brings up the question of creating some integrety checking tools for conf files
Where was the comma missing?