SimpleSearch Timing out on the server

I seem to be having some issues with SimpleSearch

Fatal error: Allowed memory size of 805306368 bytes exhausted (tried to allocate 262144 bytes) in /../public_html/core/xpdo/xpdo.class.php on line 596

When I search a two word phase no problem…

eg. explore sheet
It returns results
If i search “explore”
it times out and gives meme the above error.

my form

<form class="simplesearch-search-form" action="[[~[[+landing]]]]" method="[[+method:default=`get`]]">
    <div class="form-group">

<label for="[[+searchIndex]]">[[%simplesearch.search? &namespace=`simplesearch` &topic=`default`]]</label>
        <input class="form-control form-control-lg" type="text" placeholder="Search" name="[[+searchIndex]]" id="[[+searchIndex]]" value="[[+searchValue]]" />
        <input type="hidden" name="id" value="[[+landing]]" />

        <input class="btn btn-team-default m-0 mt-5 " type="submit" value="[[%simplesearch.search? &namespace=`simplesearch` &topic=`default`]]"/>
    </div>
</form>

my chunk

<div class="container">
<div class="row">
<div class="col-md-10 mx-auto my-3">[[!SimpleSearchForm?&tpl=`EASearchForm`]]</div>
</div>
[[!SimpleSearch?&idType=`parents`&ids=`[[*id]]`&docFields=`pagetitle,content`&includeTVs=`1`&hideMenu=`2`&showExtract=`0`&pagingSeparator=``&tpl=`EASearchResult`&containerTpl=`EASearchResults`&pageTpl=`EAPageLink`&currentPageTpl=`EACurrentPageLink`]]

<div class="row mt-5">
<div class="col-12">
<p>Click on a category to limit results to within the topic</p>
</div>
</div>

<div class="row justify-content-around mx-auto my-5">[[pdoResources? &tplFirst=`firstfaqCat` &showHidden=`1`&parents=`101`&tpl=`faqCat`&depth=`0`&showLog=`0`]]</div>
</div>


The error suggests that the program doesn’t time out but runs out of memory.

  • Are there a lot of resources that contain the word “explore”?
  • If you try using a less common single word for the search, does that work?

its about 40 articles but they are no more than 200 words.
It just wondered if it it was searching outside of the parameter I have set
I am thinking maybe there is stray character as I coped and pasted a lot of articles

I have checked for stray characters

Ok - I have also now noticed that

Sometimes it will return 4 pages of results - if you click page 2 offset 10 - nothing happens - click page 3 offset 20 they render

nothing in the error log

Maybe you can try (temporarily) adding these two lines

$c->prepare();
$this->modx->log(modX::LOG_LEVEL_ERROR,'SQL = ' . $c->toSQL());

to the code here

That outputs the used SQL query to the error log so you can check what’s actually queried.

that is a very big log… 7mb

[2021-12-08 12:23:11] (ERROR @ /home/customer/.../public_html/core/components/simplesearch/model/simplesearch/driver/simplesearchdriverbasic.class.php : 261) SQL = SELECT DISTINCT `modResource`.`id` AS `modResource_id`, `modResource`.`type` AS `modResource_type`, `modResource`.`contentType` AS `modResource_contentType`, `modResource`.`pagetitle` AS `modResource_pagetitle`, `modResource`.`longtitle` AS `modResource_longtitle`, `modResource`.`description` AS `modResource_description`, `modResource`.`alias` AS `modResource_alias`, `modResource`.`alias_visible` AS `modResource_alias_visible`, `modResource`.`link_attributes` AS `modResource_link_attributes`, `modResource`.`published` AS `modResource_published`, `modResource`.`pub_date` AS `modResource_pub_date`, `modResource`.`unpub_date` AS `modResource_unpub_date`, `modResource`.`parent` AS `modResource_parent`, `modResource`.`isfolder` AS `modResource_isfolder`, `modResource`.`introtext` AS `modResource_introtext`, `modResource`.`content` AS `modResource_content`, `modResource`.`richtext` AS `modResource_richtext`, `modResource`.`template` AS `modResource_template`, `modResource`.`menuindex` AS `modResource_menuindex`, `modResource`.`searchable` AS `modResource_searchable`, `modResource`.`cacheable` AS `modResource_cacheable`, `modResource`.`createdby` AS `modResource_createdby`, `modResource`.`createdon` AS `modResource_createdon`, `modResource`.`editedby` AS `modResource_editedby`, `modResource`.`editedon` AS `modResource_editedon`, `modResource`.`deleted` AS `modResource_deleted`, `modResource`.`deletedon` AS `modResource_deletedon`, `modResource`.`deletedby` AS `modResource_deletedby`, `modResource`.`publishedon` AS `modResource_publishedon`, `modResource`.`publishedby` AS `modResource_publishedby`, `modResource`.`menutitle` AS `modResource_menutitle`, `modResource`.`donthit` AS `modResource_donthit`, `modResource`.`privateweb` AS `modResource_privateweb`, `modResource`.`privatemgr` AS `modResource_privatemgr`, `modResource`.`content_dispo` AS `modResource_content_dispo`, `modResource`.`hidemenu` AS `modResource_hidemenu`, `modResource`.`class_key` AS `modResource_class_key`, `modResource`.`context_key` AS `modResource_context_key`, `modResource`.`content_type` AS `modResource_content_type`, `modResource`.`uri` AS `modResource_uri`, `modResource`.`uri_override` AS `modResource_uri_override`, `modResource`.`hide_children_in_tree` AS `modResource_hide_children_in_tree`, `modResource`.`show_in_tree` AS `modResource_show_in_tree`, `modResource`.`properties` AS `modResource_properties` FROM `modx_site_content` AS `modResource` LEFT JOIN `modx_site_tmplvar_contentvalues` `TemplateVarResources` ON `modResource`.`id` =  `TemplateVarResources`.`contentid` WHERE  (  ( `modResource`.`pagetitle` LIKE '%explore%' OR `modResource`.`content` LIKE '%explore%' OR `TemplateVarResources`.`value` LIKE '%explore%' )  AND  ( `modResource`.`id` != 0 AND `modResource`.`hidemenu` = 0 )  AND `modResource`.`id` != 0 AND  ( `modResource`.`id` IN ('101','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','198','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222') AND `modResource`.`published` = 1 AND `modResource`.`searchable` = 1 AND `modResource`.`deleted` = 0 AND `modResource`.`context_key` IN ('web') )  )  

So I all my pagetitles are FAQ questions with ? at the end - I think where the search term I am looking for is next to the ? its creates a problem .i.e. what is 360explore? when I search for explore…

That a question mark in the title would create problems doesn’t make much sense.


The SQL query looks ok. Does it work when you run it in phpMyAdmin?

SELECT DISTINCT *
FROM `modx_site_content` AS `modResource` 
LEFT JOIN `modx_site_tmplvar_contentvalues` `TemplateVarResources` ON `modResource`.`id` =  `TemplateVarResources`.`contentid` 
WHERE  (  
	( `modResource`.`pagetitle` LIKE '%explore%' OR `modResource`.`content` LIKE '%explore%' OR `TemplateVarResources`.`value` LIKE '%explore%' )  
	AND  ( `modResource`.`id` != 0 AND `modResource`.`hidemenu` = 0 )  
	AND `modResource`.`id` != 0 
	AND ( `modResource`.`id` IN ('101','145','146','147','148','149','150','151','152','153','154','155','156','157','158','159','160','161','162','163','164','165','166','167','168','169','170','171','172','173','174','175','176','177','178','179','180','181','182','183','184','185','186','187','188','189','190','191','192','193','194','195','196','197','198','199','200','201','202','203','204','205','206','207','208','209','210','211','212','213','214','215','216','217','218','219','220','221','222') 
	AND `modResource`.`published` = 1 
	AND `modResource`.`searchable` = 1 
	AND `modResource`.`deleted` = 0 
	AND `modResource`.`context_key` IN ('web') ) 
)

Do you do something special in your templates (“EASearchResult”, “EASearchResults”, …)?
Maybe try if you have the same problems with the standard templates.

Same problem with the standard templates…

I removed pagetitle from the docfields and it runs without it…

here are my templates


  <div class="accordion-item bg-light">
    <p class="accordion-header text-left" id="flush-heading[[+idx]]">
      <button class="accordion-button collapsed btn-block text-left bg-light border-0" type="button" data-bs-toggle="collapse" data-bs-target="#accordion[[+idx]]" aria-expanded="false" aria-controls="flush-collapse[[+idx]]">
       [[+idx]].  [[+pagetitle]]
      </button>
    </p>
    <div id="accordion[[+idx]]" class="accordion-collapse collapse" aria-labelledby="flush-heading[[+idx]]" data-bs-parent="#accordionFlushFAQ">
      <div class="accordion-body mx-3">[[+content]]</div>
    </div>
  </div>
<div class="row">
<div class="col-md-10 mx-auto">
<p class="">[[+resultInfo]]</p>


<div class="accordion" id="accordionFlushFAQ">
    [[+results]]
	</div>


<ul class=" pagination">

    [[+paging]]
</ul>
</div>
</div>


YES

Yeah, I have no clue.

These 21 rows shouldn’t cause memory problems.
I tested it locally with “explore?” in the pagetitle and it worked without problems.

No idea what is going on.

1 Like

:sweat_smile: thanks for your help

Does the page that runs the [[!SimpleSearch]] snippet have “explore” in its pagetitle?

Maybe when you include the whole [[+content]] into the result and that [[+content]] contains [[!SimpleSearch]] again, you create a recursion and SimpleSearch is called again and again.

1 Like

I think that is it! - I need to exclude the containers that have SS in for the categories.

Thank you for your help yet again…

I would have thought SimpleSearch would exclude the page with the snippet call. Do you have a SimpleSearch tag on more than one page?