I'm not quite sure what "sort the results" means here. The [subquery]
bit just adds a field to the output of the top N. So what you'd be
doing here is just getting the top 10 (if &rows=10) from your static
collection, then adding the counts to them from the "dynamic"
collection. So the sort here you're asking for would not be ordered by
actual counts in the dynamic collection, the 11th document may have a
count much greater than anything in the results list.
If anything you need to turn it around and query your dynamic
collection and add [subquery] to the top N from your static
collection.

Best,
Erick

Best,
Erick

On Mon, Nov 27, 2017 at 1:39 PM, Jinyi Lu <jin...@vmware.com> wrote:
> Hi all,
>
> I have a question about how to sort results based on the fields in the 
> subquery. It’s exactly same as this question posted on the stackoverflow 
> https://stackoverflow.com/questions/47127478/solr-how-to-sort-based-on-subquery
>  but no answer yet.
>
> Basically, I have two collections:
>
>   1.  Static data like the information about the objects.
> {
>   "id": "a",
>   "type": "type1"
> }
>
>   1.  Status about the objects in the previous collection which will be 
> frequently updated.
> {
>   "object_id": "a",
>   "cnt": 1
> }
>
> By using queries like q=id:*&fl=*,status:[subquery]&status.q= status.q={!term 
> f=object_id v=$row.id}, I am able to combine two collections together and the 
> response is something like:
> [{
>   "id": "a",
>   "type": "type1"
>   "status":{"numFound":1, "start":0, "docs":[
> {
>   "object_id": "a",
>   "cnt": 1
> }]
>   }
> },
> …]
>
> But is there a way to sort the results based on the fields in the subquery, 
> like "cnt" in this case? Any ideas are appreciated!
>
> Thanks!
> Jinyi

Reply via email to