Jump to content

Search template and Repeatable fields – not returning search result


Alex
 Share

Recommended Posts

Hi,

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
page.

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

thanks

Alex

Link to comment
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
Link to comment
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

Link to comment
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?

Link to comment
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
Link to comment
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');
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...