Fixed order in search results
Hey Low
Does the search ordering override the fixed_order parameter of the core entries tag? I am looking to order search results by their position in Structure and can get the IDs but when I pass them in to the results, it seems they're being ignored:
{exp:low_search:results
query="{embed:query}"
limit="10"
category="{embed:category_id}"
entry_ids="{structure:child_ids_for:13}"
fixed_order="{structure:child_ids_for:13}"
}
Thanks
Replies
Low 6 Sep 2013 09:33
Yeah, it does. Low Search will set the fixed_order parameter if no orderby="" param is set. You can try and set it to see if that gives you the desired results.
Also, any entry ID that is present in the entry_id parameter (you've got a typo there, "entry_ids"), are taken into account with Low Search.
So, does this work?
Russ Back 6 Sep 2013 10:32
Thanks Low. Unfortunately though when I use the entry_id parameter, I get no results, regardless of the orderby value.
Low 6 Sep 2013 10:33
Can you turn on template debugging and copy/paste the bits that concert Low Search here?
Russ Back 6 Sep 2013 11:08
I've stripped the template right back to just search and hardcoded what were embed vars, so now the template looks like this:
I get results when I take out entry_id, none when I add it in and this is the debugging info with it in:
(0.010644 / 2.01MB) - Beginning Tag Processing -
(0.010670 / 2.01MB) Parsing Tags in Template
(0.010808 / 2.02MB) Tag: {exp:low_search:results query="eyJjb2xsZWN0aW9uIjoiY29uc3VsdGFudHMiLCJyZXF1aXJlX2FsbCI6ImNhdGVnb3J5IiwicmVzdWx0X3BhZ2UiOiJzZWFyY2hcL2NvbnN1bHRhbnRzIiwic2VhcmNoX21vZGUiOiJhbGwifQ" limit="10" category="19" entry_id="{structure:child_ids_for:13}" fixed_order="{structure:child_ids_for:13}" orderby="foo" }
(0.010931 / 2.02MB) Closing Tag Found
(0.011014 / 2.02MB) Processing Tags
(0.011047 / 2.02MB) Module Tag: Low_search/results
(0.011063 / 2.02MB) Including Files for Plugins and Modules
(0.022759 / 2.48MB) Files for Plugins and Modules All Included
(0.023659 / 2.50MB) Beginning Final Tag Data Processing
(0.024071 / 2.50MB) Calling Class/Method: Low_search/results
(0.025344 / 2.51MB) -> Class Called: Low_search
(0.026851 / 2.71MB) -> Method Called: results
(0.028511 / 2.74MB) Low Search: Limiting search by entry ids
(0.031364 / 2.77MB) Low Search: No search, just filter entries by given parameters
(0.033033 / 2.78MB) Low Search: Calling the channel module
(0.044806 / 3.38MB) Returning No Results Content
(0.044858 / 3.37MB) Returning No Results Content
(0.044946 / 3.36MB) -> Data Returned
(0.045004 / 3.34MB) - End Tag Processing -
(0.045362 / 3.35MB) Calling Extension Class/Method: Automin_ext/template_post_parse
(0.046572 / 3.36MB) Calling Extension Class/Method: Structure_ext/template_post_parse
(0.046772 / 3.36MB) - End Template Processing -
(0.046786 / 3.36MB) Parse Global Variables
(0.047996 / 3.36MB) Template Parsing Finished
Low 6 Sep 2013 11:13
I can see this in the log:
The {structure...} variables aren't parsed before the low_results:results tag, so they are taken literally. That might explain why it's not working. Do you know when these vars are supposed to be parsed? I'm not familiar enough with Structure to know this...
Russ Back 6 Sep 2013 11:15
Yeah I spotted that after posting. I don't know to be honest. I tried moving that tag to the parent template and passing them in as an embed var but that seems to trip up the template parser, as I then get this output directly to the view, rather than executed:
Will pick up with the structure guys.
Russ Back 6 Sep 2013 11:20
Structure support issue is here for reference: http://structure.tenderapp.com/discus...
Low 6 Sep 2013 12:37
Oh, and by the way, the fixed_order param is only set by Low Search for keyword searches. The query present in the log has no keywords, therefore the fixed_order param is not touched by Low Search.
As soon as the Structure vars are parsed correctly, the results tag should give the correct output.
Russ Back 6 Sep 2013 14:12
That example was a search for a category but without (optional) keywords. So presumably that means that even if we can get around the structure parse issue, it wouldn't give us what we were looking for anway?
Low 6 Sep 2013 14:27
Currently, the fixed_order parameter will override the filtering by keyword. So indeed, that wouldn't produce the results you'd want.
Just setting the entry_id parameter will produce the right results, but not in the order you'd want.
I'll need to think a bit about this to see what the best approach is for custom search results ordering.
Russ Back 6 Sep 2013 14:33
Thanks Low