ElasticPress icon indicating copy to clipboard operation
ElasticPress copied to clipboard

Support orderby post__in

Open tlovett1 opened this issue 7 years ago • 6 comments

orderby in WP_Query supports post__in. We should support this in EP.

tlovett1 avatar Mar 17 '17 02:03 tlovett1

I try to solve this but ES doesn't allow to sort by field, it only allow sort by asc or desc https://www.elastic.co/guide/en/elasticsearch/reference/current/search-request-sort.html#_sort_order

@tlovett1 Do you have any pointers how to achieve this?

ivankristianto avatar May 28 '17 11:05 ivankristianto

I did ask in stackoverflow, and ES doesn't have custom sort order. But we can achieve that by weighting the data: https://stackoverflow.com/questions/44226928/how-to-sort-by-field-in-elasticsearch/44227402#44227402

ivankristianto avatar May 29 '17 05:05 ivankristianto

What is the LOE for this?

tlovett1 avatar Jul 11 '17 13:07 tlovett1

We're getting 100MB+ logs on a site we're running every day in ES logs due to lack of support here. Anything we can do to help? In the meantime, we may have to add an unmapped_type parameter to suppress the issue.

JustinSainton avatar Jul 24 '17 17:07 JustinSainton

@JustinSainton would be happy to review a PR :) Wish I had a quick fix for this one.

tlovett1 avatar Jul 24 '17 20:07 tlovett1

@felipeelia

Do we have any news regarding this Bug?

I am getting the following error:

No mapping found for [post__in] in order to sort on

The field post__in was not found. Make sure it is added to the list of indexed fields and run a new sync to fix the issue.

The field post__in was not found. Make sure it is added to the list of indexed fields and run a new sync.

{
  "from": 0,
  "size": 9,
  "post_filter": {
    "bool": {
      "must": [
        {
          "bool": {
            "must": {
              "terms": {
                "post_id": [
                  130737,
                  130721
                ]
              }
            }
          }
        },
        {
          "terms": {
            "post_type.raw": [
              "product"
            ]
          }
        },
        {
          "term": {
            "post_status": "publish"
          }
        }
      ]
    }
  },
  "query": {
    "match_all": {
      "boost": 1
    }
  },
  "_source": {
    "includes": [
      "post_id"
    ]
  },
  "sort": [
    {
      "post__in": {
        "order": "desc"
      }
    }
  ]
}

creative-andrew avatar Jan 16 '23 16:01 creative-andrew