You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by tedsolr <ts...@sciquest.com> on 2015/01/27 16:58:47 UTC

Dynamically change sort?

Hi. I'm trying to sort on computed values that my QParserPlugin creates. I've
found out that I can make it happen by adding a fake scorer to the delegates
before collect() is called. The problem I have now is how to modify the sort
field in mid stream?

The user selects COUNT as a sort field, but of course that is not a real
field. I can examine the SolrParams and see that COUNT is the sort field. I
can use that info to build my document scores properly for the computed
counts. But the search still sorts on COUNT (which produces an error of
course).

If I only had one computed value to worry about for sorting, I could change
"COUNT" to "score" before the query request is initiated and all would be
well. But I have 2 computed values - so I need to know which one was
selected by the user.

Will any of these ideas work?
1) Pass some dynamic data to my Plugin that will tell me what the user wants
to sort on, and set sort=score in the search request?
2) Change the sort param within my plugin (from COUNT or SPEND to score)?
(using Solr 4.9)



--
View this message in context: http://lucene.472066.n3.nabble.com/Dynamically-change-sort-tp4182264.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Dynamically change sort?

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
the last advice, have a look how Solr modifies params by chaining, defaults
and appends. I don't know why it's exactly done in such trendy way. It just
seems serious. Keep the same way.

On Tue, Jan 27, 2015 at 8:58 PM, tedsolr <ts...@sciquest.com> wrote:

> Brilliant! I didn't know what the prepare() method of a SearchComponent
> could
> do. I can modify the SolrParams by request.setParams() and add custom data
> to the request context to tell my Collector how to figure the score. Thank
> you!
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Dynamically-change-sort-tp4182264p4182306.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>

Re: Dynamically change sort?

Posted by tedsolr <ts...@sciquest.com>.
Brilliant! I didn't know what the prepare() method of a SearchComponent could
do. I can modify the SolrParams by request.setParams() and add custom data
to the request context to tell my Collector how to figure the score. Thank
you!



--
View this message in context: http://lucene.472066.n3.nabble.com/Dynamically-change-sort-tp4182264p4182306.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Dynamically change sort?

Posted by Mikhail Khludnev <mk...@griddynamics.com>.
Hello,

you can modify query params in prepare() before QueryComponent. You can set
sorting to score and turn your component to compute it based on params.
Just an oftop, literally sorting extension might be done via
FieldComparatorSource, which is described in LIA. this proper way, might
not suite for your problem.

On Tue, Jan 27, 2015 at 6:58 PM, tedsolr <ts...@sciquest.com> wrote:

> Hi. I'm trying to sort on computed values that my QParserPlugin creates.
> I've
> found out that I can make it happen by adding a fake scorer to the
> delegates
> before collect() is called. The problem I have now is how to modify the
> sort
> field in mid stream?
>
> The user selects COUNT as a sort field, but of course that is not a real
> field. I can examine the SolrParams and see that COUNT is the sort field. I
> can use that info to build my document scores properly for the computed
> counts. But the search still sorts on COUNT (which produces an error of
> course).
>
> If I only had one computed value to worry about for sorting, I could change
> "COUNT" to "score" before the query request is initiated and all would be
> well. But I have 2 computed values - so I need to know which one was
> selected by the user.
>
> Will any of these ideas work?
> 1) Pass some dynamic data to my Plugin that will tell me what the user
> wants
> to sort on, and set sort=score in the search request?
> 2) Change the sort param within my plugin (from COUNT or SPEND to score)?
> (using Solr 4.9)
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Dynamically-change-sort-tp4182264.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>



-- 
Sincerely yours
Mikhail Khludnev
Principal Engineer,
Grid Dynamics

<http://www.griddynamics.com>
<mk...@griddynamics.com>