Indexed-Search - Configuration
I'm not sure whether this is a mere Documentation issue, or really a bug. Clearly, the documentation for the latest indexedsearch version is wrong.
The docs state:
search.rootPidList should be set to the required pageID to only show the results of a subset of the Website tree.
This is wrong.
a) it's not search.rootPidList but settings.rootPidList
b) When this is set to a number higher than 1 in the TS-config, the plugin always returns 0 results.
This is because the value is compared to index_section.rl0. But the value of this table-field is always 1, i.e. the root page of the website.
So setting the config-value to something greater than 1 never returns true in the query.
The function sectionTableWhere() on Row 788 of the file indexed_search/Domain/IndexSearchRepository.php creates the query and if the class variable SearchRootPageIdList is 0 or bigger, it sets a WHERE-clause of ISEC.rl0 to compare to the value of settings.rootPidList (row 796).
But, as mentioned before, this will never return a positive result. I don't know whether this is intentional or a bug.
To achieve the required result (i.e. searching only a subpart of the website tree), the correct setting in the TS is:
plugin.tx_indexedsearch.settings.defaultOptions.sections = rl1_xxx (where xxx is the id of the required top page to be searched).
So, if it's a bug, it should be fixed. If it's just me misinterpreting the docs, at least the docs should be updated with the correct information, like mentioned above. In any case, it's misleading and I found quite a lot people on the web with the same problem (their solution never worked for the current version of indexedsearch, though, so I had to dig through the code to find the correct way for myself).
#3 Updated by Sybille Peters 10 months ago
Thanks for pointing this out.
Analyzing the problem¶
You are right, it is plugin.tx_indexed_search.settings.rootPidList, not plugin.tx_indexed_search.search.rootPidList
I think one misunderstanding is, you can't just use any page for rootPidList, it must be the root page (meaning the page with the root template). So if a page 955 is indexed and the page tree looks like this:
3 | > 14 | > 79 | > 54044
and page id 3 is our root page,
The page 54044 will always be indexed like this:
rl0 | rl1 | rl2 | page_id ----|-----|-----| 3 | 14 | 79 | 54044
You will not get any results, with rootPidList being a list of or one non-root page(s). As you found out, he will just check for the field rl0.
Now the docs do point this out (somewhat): "Notice that by "root-page" we mean a website root defined by a TypoScript Template! If you just want to search in branches of your site, use the possibility of searching in levels."
but I agree, they could be clearer. Also the statement "If you just want to search in branches of your site, use the possibility of searching in levels" is very vague and only adds to the frustration. At least a link at that point would be helpful.
Actually, your method:
plugin.tx_indexedsearch.settings.defaultOptions.sections = rl1_xxx
does work, but only if the page you are using for rl1_xxx is a direct subpage of the root page. If it's a sub-subpage you must use rl2_xxx and if it is further down in the page tree, you are out of luck.
Disclaimer: I'm just guessing here, but it makes sense and tests confirm.
What to do¶
You might consider submitting a patch, even if it's just for the documentation clarification. You already proceeded so far. Please see the Contribution Guide for more information. Don't worry, your patch will be reviewed before it is merged.