Open smithsc2 opened 4 years ago
Thank you for the detailed bug report @smithsc2 Clearly you’ve done this before ;)
The error from your log indicates the use of pdoTools and the pdoParser class.
Thanks again!
Many times as part of the regular maintenance cycle at work ;)
While I do have pdoTools on the site I'm not using it as part of the search. I'm attempting to implement this as a replacement for SimpleSearch as so far it returns much more meaningful results than I was ever able to get using it, so I'm still using some of the same chunks for my search form and results but they are for the most part basic html, nothing complicated. Though I will admit to not being overly familiar with the inner workings of modx, just some interesting quirks based on how we have it set up.
I had originally set FullTextSearch up using getResources but that doesn't easily allow for pagination so I had replaced it with getPage.
As you've suggested I created a testing template for this and removed anything extra (css, js, anything else) but I get the same error using either getResources or getPage. It looks like this:
getResources
[[!FullTextSearch? &searchParam =
searchField &scoreThreshold =
1.5 &toPlaceholder =
results &parents =
[[!getReqParam? &name=resource-filters
]]`
]]
<ul class="sisea-results-list">
[[!getResources?
&resources = `[[!+results]]`
&depth = `2`
&sortBy=`FIELD(modResource.pagetitle, [[!+results]]`
&tpl = `searchItems`
&limit = `10`
&offset = `[[!getReqParam? &name=`sisea_offset`]]`
]]
</ul>
<ul class="page-list">[[!+page.nav]]</ul>
`
getPage:
[[!FullTextSearch? &searchParam =
searchField &scoreThreshold =
1.5 &toPlaceholder =
results &parents =
[[!getReqParam? &name=resource-filters
]]`
]]
<ul class="sisea-results-list">
[[!getPage?
&elementClass = `modSnippet`
&element = `getResources`
&resources = `[[!+results]]`
&sortBy=`FIELD(modResource.pagetitle, [[!+results]]`
&tpl = `searchItems`
&limit = `10`
&offset = `[[!getReqParam? &name=`sisea_offset`]]`
]]
</ul>
<ul class="page-list">[[!+page.nav]]</ul>
Errors obtained using &debug =
log`
[2019-12-18 16:05:48] (ERROR @ core/cache/includes/elements/modsnippet/115.include.cache.php : 115) SELECT fts.content_id FROM (SELECT content_id, content_parent, MATCH (content_output) AGAINST (' foor + bar' IN BOOLEAN MODE) AS score FROM modx_fts_content WHERE MATCH (content_output) AGAINST (' foor + bar' IN BOOLEAN MODE) ) AS fts WHERE fts.score > 1.5 AND fts.content_parent IN (2,40,1410,44,4886,1404,3875,6222) ORDER BY fts.score DESC ;
[2019-12-18 16:05:48] (ERROR @ core/cache/includes/elements/modsnippet/115.include.cache.php : 116) Array ( [0] => 2379 [1] => 2781 [2] => 2628 [3] => 2380 [4] => 2383 [5] => 4893 ) [2019-12-18 16:06:01] (ERROR in modMenu::getSubMenus @ core/model/modx/modmenu.class.php : 145) modAction support is deprecated since version 2.3.0. Support for modAction has been replaced with routing based on a namespace and action name. Please update the extra with the namespace fulltextsearch to the routing based system.
I figured out what the problem is. The query gets run, but returns mysql throws an error: 1064 - syntax error, unexpected '+'
for
SELECT fts.content_id FROM (SELECT content_id, content_parent, MATCH (content_output) AGAINST ('foo + + bar' IN BOOLEAN MODE) AS score FROM modx_fts_content WHERE MATCH (content_output) AGAINST (' foo + + bar' IN BOOLEAN MODE)) AS fts WHERE fts.score > 1.5 AND fts.content_parent IN (2,40,1410,44,4886,1404,3875,6222) ORDER BY fts.score DESC;
So core/xpdo/xpdo.class.php line 2541 $return= $this->pdo->query($query);
returns false, because mysql doesn't like '+ +' in the query. In turn it isn't handled gracefully which got me the error page.
Yep that does look like a problem. I’ll look into further tomorrow and will target a fix for next release.
As an aside, the sortBy property for getResources seems like it’s comparing pagetitle to IDs.
It looks like it is! I'll have to do something about that, thank you!
I also noticed (provided I understand the query and Digital Ocean article) that the query won't return the expected results as it is in Boolean Mode. You can still get results, but they'll be the same as the results from Natural Language Mode. I'll raise it as a separate issue, however I should be able to get something working in the meantime.
EDIT
Read some more about it, and it does work properly just not as I expected and there's no ability to have something like '"traveling miles" @4' IN BOOLEAN MODE
in the query which is what I am looking to do
Description
While attempting to implement and test this extra for search functionality on the website I maintain I was attemping to get meaningful results from the query IN BOOLEAN MODE and ended up inputting + + in my search box. Upon submitting the search I was greeted with a white page and a fatal error.
Steps to Reproduce
The Error
Fatal error: Uncaught Error: Call to a member function fetchAll() on boolean in core/cache/includes/elements/modsnippet/115.include.cache.php:102 Stack trace: #0 core/model/modx/modscript.class.php(76): include() #1 core/model/modx/modparser.class.php(537): modScript->process(NULL) #2 core/components/pdotools/model/pdotools/pdoparser.class.php(273): modParser->processTag(Array, true) #3 core/model/modx/modparser.class.php(251): pdoParser->processTag(Array, true) #4 core/components/pdotools/model/pdotools/pdoparser.class.php(65): modParser->processElementTags('[[$sectionBody?...', '$sectionBody?\n ...', true, false, '[[', ']]', Array, 0) #5 core/model/modx/modparser.class.php(431): pdoParser->processElementTags('[[$sectionBody?...', '$sectionBody?\n ...', true) #6 /var/www/html/core/components/pdotools/model/pdotools/pdoparser.class.php(273): modParser->processTag(Array, true) #7 core/model/modx/modparser.class.p in core/cache/includes/elements/modsnippet/115.include.cache.php on line 102