Jump to content

Search template and Repeatable fields – not returning search result

Recommended Posts


I am using the basic search template from the processwire install. I havn't been able to return any search results from text contained in repeater fields. I have added the repeater field name and all fields contained inside it to my search template.

On processwire.com i have found this post in the comments area by someone:

It should be noted that a search will not yield any hits from repeater
fields. I guess that is because the content actually belongs to a hidden

Is there any way around this, or are repeaters left out of search results?



Share this post

Link to post
Share on other sites

Hi, Alex.

I think that the following code should work:

$found = $pages->find('myrepeater.summary*=hello');

Maybe you should try this:

$found = $pages->find('myrepeater.summary*=hello, include=all');

But then it doesnt check access rights and published/unpublished state of your pages.

Maybe you should post your code here so others can see it.

  • Like 1

Share this post

Link to post
Share on other sites

Hi there,

I ran encountered exactly the same problem a few minutes before - now I had a look at the original search template:

$matches = $pages->find("title|body|sidebar~=$q, limit=50"); 

Does this mean that the selectors above overwrite the module settings?

Cheers, Christian

Share this post

Link to post
Share on other sites

In fact it's a little confusing: 

In the module settings you can define the default fields to search and the default field names which should be displayed in the results.

In the search template both parameters are defined again - do the module settings make any sense then?

Share this post

Link to post
Share on other sites

Hi, Doolak.

I think there's some confusion going on :huh:

Search module (ProcessPageSearch)is purposed solely for back-end usage: it runs when you hit search in the admin interface (and you get to the back-end search page whare you can see the default settings you mentioned). The default settings of this module don't affect  your template code, they are totally independent. Your selector, access rights and page status are three things that define the results you get when you search via api.

It seems though, there's no way to search repeater fields with ProcessPageSearch at the moment. Correct me if I'm missing something.

  • Like 1

Share this post

Link to post
Share on other sites

Hi slkwrm,

yes - recognized that mistake - just found the description of the module: "Provices a page search engine for admin use." ...

Searching repeater fields through the API seems to work fine here the way you described it, thanks a lot!

$matches = $pages->find('myrepeater.myrepeaterfield*=$q');

Share this post

Link to post
Share on other sites

Thanks Slkwrm & Doolak

$matches = $pages->find('myrepeater.myrepeaterfield*=$q');

Works for me too.


Share this post

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Similar Content

    • By jds43
      I have a search page loosely based on Skyscrapers where I'm parsing a selector with options 'beds', 'bathrooms', 'size' fields. It is working well until I select 'Any' after I've run a search. This is where no results are returned (/?beds=&bathrooms=&size=&submit=). I want it to reset and show all results.
      I hope this isn't too vague.
    • By sww
      Hey there,
      i am trying to add a kind of "intelligent" search.
      Is there any way to ignore punctuation and extra chars.
      When I type "somebody elses" that I still get the result "SOMEBODY ELSE´S CAR, 2005"
      The problem is the extra ´ … if I don't type it I don't get the result.
      So far I am using %=query (which isn't enough, I know)
      So the idea would be something like that:
      $selector = "sanitize(title|text)%=$q, limit=50";
      I know, it's not gonna work like that … just to illustrate.
    • By dandeckr
      I'm making my way through my first encounter with ProcessWire, and I'm very near the end of my tasks! I've searched Google, these forums, and for add-ons, but I haven't found any documentation or reference work for implementing boolean searching in the native CMS? Am I missing a thread, add-on, or docs that can point the way? I'm sure I'm not the first to have a need like this? Thanks in advance! 
    • By MateThemes
      Hello everyone!
      I am trying to add my repeater matrix fields to the search selector, but unfortunately nothing seems to work for me.
      I have following search code in my search.php:
      <?php namespace ProcessWire; // look for a GET variable named 'q' and sanitize it $q = input()->get('q'); // sanitize to text, which removes markup, newlines, too long, etc. $q = sanitizer()->text($q); // did $q have anything in it after sanitizing to text? if($q) { // Make the search query appear in the top-right search box. // Always entity encode any user input that also gets output echo '<input id="search-query" value="' . sanitizer()->entities($q) . '">'; // Sanitize for placement within a selector string. This is important for any // values that you plan to bundle in a selector string like we are doing here. // It quotes them when necessary, and removes characters that might cause issues. $q = sanitizer()->selectorValue($q); // Search the title and body fields for our query text. // Limit the results to 50 pages. The has_parent!=2 excludes irrelevant admin // pages from the search, for when an admin user performs a search. $selector = "title|body~=$q, limit=50, has_parent!=2"; // Find pages that match the selector $matches = pages()->find($selector); } else { $matches = array(); } // unset the variable that we no longer need, since it can contain user input unset($q); ?> <main pw-replace='main'> <?php include('./includes/_pageheadersearch.php'); ?> <div id='content-body' class='uk-section uk-section-large uk-section-large'> <div class='uk-container uk-container-small'> <?php // did we find any matches? if(count($matches)) { // yes we did, render them echo ukAlert(sprintf(_n('Found %d page', 'Found %d pages', $matches->count), $matches->count), "default", "check"); echo ukDescriptionListPages($matches); } else { // we didn't find any echo ukAlert(__('Sorry, no results were found'), "danger", "warning"); } ?> </div> </div> </main> I have tried to add my fields to the selector code (repeater_matrix.aboutsblock_repeaters.mytextfield) . But I didn't get any results.
      What I am doing wrong?
      Thanks for your help!
    • By Violet
      I've been trying to figure this out... It seems like I'm probably missing something really simple, but I'm still puzzled as to how to move forward with this. I'd appreciate any help or suggestions anyone can give.
      Aim: I'm trying to modify the default search template so that my search results come out sorted firstly with those which contain the search term in the title and secondly with those that contain it in the body.
      The basic code where I made sure everything was working first was:
      $selector = "title|body~=$q, template=BN-article|BN-infopage, sort=-published, limit=15"; // Find pages that match the selector $matches = $pages->find($selector); // did we find any matches? if($matches->count) { // yes we did $entries = $matches; include("./INC-main-blogroll-panels.html"); } It gave me the search results sorted by publication date, as I expected.
      Next I modified the first portion of the code by using the following to generate the matches as follows:
      $matchest = $pages->find("title~=$q, template=BN-article|BN-infopage"); $matchesb = $pages->find("body~=$q, template=BN-article|BN-infopage"); $entries = $matchest->and($matchesb); However, the problem is that $entries in my resultant displayed list did NOT start with those matches that were in the title first from $matchest. It seemed like $matchest->and($matchesb) sorted the resultant list its own way. This is even without the added complication of trying to use unique() afterward to remove duplicates - which appears to have its own default sort.
      Would anyone please point me in the right direction for what what I'm seeking to do? Thank you so much!
  • Create New...