Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support orderby post__in #773

Open
tlovett1 opened this issue Mar 17, 2017 · 6 comments
Open

Support orderby post__in #773

tlovett1 opened this issue Mar 17, 2017 · 6 comments
Labels
enhancement low priority module:posts Issues related to the Posts Indexable / Feature.

Comments

@tlovett1
Copy link
Member

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

@ivankristianto
Copy link
Contributor

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
Copy link
Contributor

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

@allan23 allan23 self-assigned this Jun 27, 2017
@tlovett1
Copy link
Member Author

What is the LOE for this?

@JustinSainton
Copy link

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.

@tlovett1
Copy link
Member Author

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

@creative-andrew
Copy link

creative-andrew commented Jan 16, 2023

@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"
      }
    }
  ]
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement low priority module:posts Issues related to the Posts Indexable / Feature.
Projects
None yet
Development

No branches or pull requests

6 participants