20

I am trying to sort search results by a date across multiple pages of results. Sorting is working within each page, is there a way to sort across the entire set?

For example: If page 1 has items from Feb 13 through Feb 1st; the second page should not have items after Feb 1st.

Here is a brief snippet of the request that I am sending. I have also tried sorting by date then _score, but that produced even stranger results (primarily, the sort order was the same).

{
  "query": {
    "from": 0,
    "size": 24
    "sort": [
      "published_on": {
        "missing": "_last",
        "ignore_unmapped": true,
        "order": "desc"
      }
    ]
    "custom_filters_score": {
      "query": {
        "bool": {
          "must": [
            {
              "match": {
                "content": "Some query"
              }
            }
          ]
          ... more ...
        }
      },
      "filters": [
        {
          "filter" => {
            "type" => {
              "value" => "cats"
            }
          },
          "boost" => 2
        }
        ... more ...
      ]
    }
  }
}

Any thoughts? Thanks in advance!

4
  • It should be date then _score. Please consider including your "strange" results in the question. Somebody might be able to explain why they are so strange. Commented Feb 14, 2013 at 2:48
  • As I said in the question I tried sorting by date then _score. I will try to put up some results today. Commented Feb 14, 2013 at 16:20
  • Sorry, I didn't read your comment well enough to catch what you are saying. As of right now the _sort is not in place and I am still seeing the same results. Commented Feb 14, 2013 at 20:36
  • How is published_on indexed? Commented Feb 14, 2013 at 21:20

2 Answers 2

20

I was not multiplying the page index by the number of items on the page. I'm not sure how I missed the same entires on every page, moved up by a single spot.

I'm sure this will resolve all of the other odd issues that I have been dealing with.

Sign up to request clarification or add additional context in comments.

1 Comment

:-) We've all been in a similar spot, I'm sure.
8

sort, size, from must be in the root

    {
       query:{
          ...
       },
       sort:[
         ...
       ],
       from:15,
       size:5
    }

Search API - Sort

1 Comment

hello sir please can you answer on my stackoverflow.com/questions/35719728/… it is also about pagination

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.