Uploaded image for project: 'Solr'
  1. Solr
  2. SOLR-4235

Solr join or subquery should support sorting (and perhaps paging)

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Major
    • Resolution: Unresolved
    • 4.0
    • None
    • None

    Description

      Suppose a list of product documents, and a list of order documents, in the same core. We want to retrieve the products ordered. With the new join syntax,
      q=

      {!join from=orderSku to=sku}accountNumber=x

      Great. Now, we wish to retrieve the products most recently ordered, by order date.

      q={!join from=orderSku to=sku}

      accountNumber=x&sort=orderDate desc
      Nope - product doesn't have an orderDate field, no effect

      q={!join from=order to=sku)query:"accountNumber:x&sort=orderDate desc"
      Nope. Parser approves it, but appears to have no effect. My guess is that sort is applied after the subquery result is effectively sent to the parent.

      So we wind up getting all of the orders by date desc, and bundling up their SKUs, and POSTing that as a big OR clause. All things that join was supposed to save us from. It would be great if there was a way to support sort on the parent instead.

      It would also be helpful if there was a way to support pagination of the parent. For example, suppose I now want to display the date of the order along side the product. I can join from product to order, but if they've paged the search result I can't page the products used in the join.

      I'd be perfectly content to use nested query syntax for both of these things - that might be more flexible overall - but it doesn't appear to work.

      Attachments

        Activity

          People

            Unassigned Unassigned
            dtertman Dan Ertman
            Votes:
            3 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated: