lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Jinyi Lu <jin...@vmware.com>
Subject Re: Sort with subquery
Date Tue, 28 Nov 2017 04:20:23 GMT
Thank you for the reply!

In terms of sort, I am wondering is it possible to sort the docs from my static collection
based on the corresponding counts in the dynamic collection, since we have combined them together
in the result.
Something like:
sort=max(status.cnt) asc

Or is it possible to add a multiValued pseudo field "cnts"  using a subquery for every static
doc in the result, and then sort the static doc by the pseudo field?
Something like:
fl=*,cnts:[subquery]&cnts.q=={!term f=object_id v=$row.id}&cnts.fl=cnt&sort=max(cnts)
asc

Thanks,
Jinyi

On 11/27/17, 6:04 PM, "Erick Erickson" <erickerickson@gmail.com> wrote:

    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 <jinyil@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://urldefense.proofpoint.com/v2/url?u=https-3A__stackoverflow.com_questions_47127478_solr-2Dhow-2Dto-2Dsort-2Dbased-2Don-2Dsubquery&d=DwIFaQ&c=uilaK90D4TOVoH58JNXRgQ&r=9_rAkkO7SJ7HHMsaZXKAFNMoKpKiTfF8Eho2F9ygvjQ&m=oA6uB1I6AEAC64URTsslH7aCCfxu34orl2K5xnzvKTQ&s=bVCaDnDL8m0xXsxi8vhCrgiUFwYVyfICucICSVrnZFk&e=
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
    

Mime
View raw message