If I set a sort on for example sort_title in the query, it doesn't care if I set a 500.0 boost on a certain field, sorting still wins, like so:

Amber <- boosted
Andrea <- normal sort_title
Beta <- boosted
Delta <- normal sort_title
Xavier <-boosted
Zebra <- normal sort_title

What I want to achieve here is a list of nodes, but like sticky nodes, have nodes with a certain value of a field come higher up, and still be sorted by title, like so:

Amber <- boosted
Beta <- boosted
Xavier <-boosted
Andrea <- normal sort_title
Delta <- normal sort_title
Zebra <- normal sort_title

Comments

JacobSingh’s picture

Status: Active » Closed (works as designed)

I think this is counter intuitive.

If you sort, boosts are tossed. Anything else would confuse people because then it isn't really sorting anymore.

If you can find something to the contrary in the Solr docs, re-open and maybe we can implement it.

blackdog’s picture

Version: 6.x-1.0-beta4 » 6.x-1.0-beta5
Status: Closed (works as designed) » Active

Sorry to re-open this, but if someone knows of a way to accomplish this, I would be much obliged!

I'm gonna look through the docs, but I thought I'd throw the question out there in the meantime.

janusman’s picture

I agree with @Jacobsingh on this being counter-intuitive. But I can think of several use cases for what you want...

Maybe you could show a block with items matching the current search, but adding a filter for "sticky"...? Not sure if we can have more than one invocation of Apache Solr search per page, though...

blackdog’s picture

I have built my own search callback, much like the project search here on d.o, so I can modify the code quite a bit if that brings up any more ideas.
I'm not to keen on having another filter/sort facet shown to the user.

pwolanin’s picture

I think Solr suppots sorting by more than one field. However, I'd stringly agree that trying to mix sort and boost doesn't make any sense. In fact - we should clean up our code so we omit all boost queries, etc, when sending a sort request to improve query speed - though maybe Solr does that for us?

blackdog’s picture

So I should implement my other field as a sorting filed instead of boosting it? Can that be done with a field that has TRUE/FALSE values only?

pwolanin’s picture

yes - I think so; I'm not sure about true/false - try it, but at the worst you could resort to using 'sortMissingLast'

blackdog’s picture

So, I tried sortMissingLast="true", which has the same effect as boosting my field. Also tried making it a sorting field, which also worked as expected. Main problem still resides though, I can't get my search result to sort by title AND this field staying on top. I can live with having the top results not sorted by title, but the rest of the result needs to.

Solr's default sort is by score desc, right? Can't this be overridden to use another field?

I'm sorry to drag out on this. If someone tells me it really can't be done, I'll leave it behind. Thanks!

blackdog’s picture

Btw - when implementing my field as a sorting field, I tried sorting like 'my_field asc, sort_title asc', but the results where sorted by title only.

pwolanin’s picture

we should check if the query handler is causing a problem, but Solr supports sorting on 2 fields like "sort=name asc,sort_title asc"

Can you remove the extra space after your comma?

see: http://wiki.apache.org/solr/CommonQueryParameters

blackdog’s picture

The space doesn't seem to matter.

Could it be that I'm using sortString for a field with 0/1 values? I've looked, but can't find a reference to a sortInteger or sortBoolean.

<field name="sort_my_field" type="sortString" indexed="true" stored="false"/>

blackdog’s picture

Status: Active » Closed (fixed)

We did fix this somehow, if someone needs the code I'll look it up. Closing for now.