@RvR, thank you. But still I have the issues I reported earlier. I can't get search result by either "title" and "description" individually. I can only get search result when I have both defined in "$fields". What I did is I copied your code to my plugin, then I deactivate my plugin and activate it again. Did I miss anything ?
Did you upgrade to initiate the code changes?
Yes I did the upgrade. Still I got the same errors. Here I copied more text from my screen.
Can't find FULLTEXT index matching the column list
QUERY: SELECT count(DISTINCT e.guid) as total FROM entities e JOIN objects_entity oe ON e.guid = oe.guid WHERE (MATCH (oe.title) AGAINST ('test' )) AND ((e.type = 'object' AND e.subtype IN (4))) AND (e.site_guid IN (1)) AND ( (1 = 1) and e.enabled='yes')
DatabaseException Object
(
[message:protected] => Can't find FULLTEXT index matching the column list
QUERY: SELECT count(DISTINCT e.guid) as total FROM entities e JOIN objects_entity oe ON e.guid = oe.guid WHERE (MATCH (oe.title) AGAINST ('test' )) AND ((e.type = 'object' AND e.subtype IN (4))) AND (e.site_guid IN (1)) AND ( (1 = 1) and e.enabled='yes')
[string:Exception:private] => exception 'DatabaseException' with message 'Can't find FULLTEXT index matching the column list
QUERY: SELECT count(DISTINCT e.guid) as total FROM entities e JOIN objects_entity oe ON e.guid = oe.guid WHERE (MATCH (oe.title) AGAINST ('test' )) AND ((e.type = 'object' AND e.subtype IN (4))) AND (e.site_guid IN (1)) AND ( (1 = 1) and e.enabled='yes')' in /var/www/html/engine/lib/database.php:274
Stack trace:
#0 /var/www/html/engine/lib/database.php(416): execute_query('SELECT count(DI...', Resource id #3)
#1 /var/www/html/engine/lib/database.php(379): elgg_query_runner('SELECT count(DI...', '', true)
#2 /var/www/html/engine/lib/entities.php(1090): get_data_row('SELECT count(DI...')
#3 /var/www/html/mod/web_services/start.php(23): elgg_get_entities(Array)
#4 [internal function]: search_objects_my_hook('search', 'object', Array, Array)
#5 /var/www/html/engine/lib/elgglib.php(989): call_user_func_array('search_objects_...', Array)
#6 /var/www/html/mod/search/pages/search/index.php(186): elgg_trigger_plugin_hook('search', 'object', Array, Array)
#7 /var/www/html/mod/search/start.php(74): include_once('/var/www/html/m...')
#8 [internal function]: search_page_handler(Array, 'search')
#9 /var/www/html/engine/lib/pagehandler.php(53): call_user_func('search_page_han...', Array, 'search')
#10 /var/www/html/engine/handlers/page_handler.php(46): page_handler('search', NULL)
#11 {main}
[code:protected] => 0
[file:protected] => /var/www/html/engine/lib/database.php
[line:protected] => 274
Utilize the pagination by limiting your queries to 10-20 items.
The heavily normalization makes the schema pretty terrible for ordering by metadata values. Ideally you can cache the query in some way.
E.g. I have an API for managing and querying from an ordered list of entities. This would remove a big join and order on an indexed id column.
@Steve Clay, I see you can feel my pain. I'll try your plugin. Thanks.
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.