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

QUESTION: about sorting #2348

Closed
dnikola opened this issue Sep 16, 2021 · 7 comments
Closed

QUESTION: about sorting #2348

dnikola opened this issue Sep 16, 2021 · 7 comments

Comments

@dnikola
Copy link

dnikola commented Sep 16, 2021

Hello,

since few last version I must admit that plugin has a great improvement.

I want to ask two question

  1. I have a custom plugin which save array of post in order that i want to display them on site. When i make query to retrieve that post's content with query i use this

`
$custom = get_option('custom_newsi');

        	$args['post__in'] = array_values($custom );
	$args['orderby'] = 'post__in';`

but es return error

"error": { "root_cause": [ { "type": "query_shard_exception", "reason": "No mapping found for [post__in] in order to sort on", "index_uuid": "xxxxxxxxx", "index": "xxxxxxxxx" } ], "type": "search_phase_execution_exception", "reason": "all shards failed", "phase": "can_match", "grouped": true, "failed_shards": [ { "shard": 0, "index": "xxxxxxxxx", "node": "xxxxxxxxx", "reason": { "type": "query_shard_exception", "reason": "No mapping found for [post__in] in order to sort on", "index_uuid": "xxxxxxxxx", "index": "xxxxxxxxx" } } ] }, "status": 400

is it possible to make some fix for this?

  1. When i open all post edit screen initially query is not made from ES, because it throw error
    "error": { "root_cause": [ { "type": "parsing_exception", "reason": "Unknown key for a VALUE_NULL in [sort].", "line": 1, "col": 28 } ], "type": "parsing_exception", "reason": "Unknown key for a VALUE_NULL in [sort].", "line": 1, "col": 28 }, "status": 400

but if i sort table by date or title, which is available only, it works without problem

  1. how to add comments to index? I see that index has been created, option to on elasticpress page has been enabled ? Should I add it array with filter available?

Regards
Nikola

@felipeelia
Copy link
Member

Hi @dnikola. First of all, I'm glad to read you saw a great improvement in the plugin. Thanks!

Regarding your problems:

  1. order_by post__in is not something we support yet. We have this issue you can follow to check our progress on that.
  2. What are you using to sort in that case?
  3. If you have enabled the Comments feature and reindexed, comments should be already there. Do you mind explaining what you are trying to achieve and how you are checking it?

Thanks!

@github-actions
Copy link

This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. See this blog post on bug reports and the importance of repro steps for more information about the kind of information that may be helpful.

@dnikola
Copy link
Author

dnikola commented Nov 7, 2021

Hi @dnikola. First of all, I'm glad to read you saw a great improvement in the plugin. Thanks!

Regarding your problems:

  1. order_by post__in is not something we support yet. We have this issue you can follow to check our progress on that.
  2. What are you using to sort in that case?
  3. If you have enabled the Comments feature and reindexed, comments should be already there. Do you mind explaining what you are trying to achieve and how you are checking it?

Thanks!

Hello @felipeelia

I am so sorry because of my late replay!
Yes i follow plugin improvement now, and it looks very stabile and good.
I would like to donate to support work, possible?

  1. Oh i see that problem persist long time, ok.. I see that this guy @JustinSainton has mention that he has added unmapped_type support, what should be this and how to add it?
  2. I didn't used anything, but when i updated plugin from 3.6.3 to 3.6.4 query started to work but it sorted in ASC direction on edit.php
    I used code
add_action( 'pre_get_posts', 'date_default_sort' );
function date_default_sort( $query ) {

	global $pagenow;
	
    if ( is_search() || ($pagenow == 'edit.php') ) {
       	$query->set('orderby', 'date');  
        $query->set('order', 'DESC'); 
    }       

} 

to fix this and it works now...

  1. regarding comment index i checked an option in plugin features but never got comment indexed. So i used wp cli to index just comments
    That was few hours ago, when it was finished, and now when I check in index comment count is 2042083 in index, but situation is different in wp-admin
    I see that now debug shows that query run trough ES, but i am not sure how much is relevant, since I see that it return 10000 posts from ES, but as I showed on previous picture, total count is 2,042,152 items, but it should be 10000 like on post edit page http://prntscr.com/1ym5m7i
    Also could be this query's replaced with ES query

@felipeelia
Copy link
Member

Hey @dnikola!

  1. You'd need to write some custom code to test that, probably using the ep_set_sort filter.
  2. That is good to know!
  3. You can see in that screenshot that although the number is 10,000, the relation is "gte" (greater than or equal). You can increase that number using the ep_max_results_window filter but that can come with a performance penalty. The plugin should probably change that to show +10,000 items though. Do you mind opening a separate issue with that?
  4. Which query are you referring to? Although ES is fast, it is not guaranteed that it will always be faster than MySQL.

Regarding donating, although you can use the donate button on this page that is really not expected from our users :) Thanks!

@dnikola
Copy link
Author

dnikola commented Nov 12, 2021

Hey @dnikola!

  1. You'd need to write some custom code to test that, probably using the ep_set_sort filter.
  2. That is good to know!
  3. You can see in that screenshot that although the number is 10,000, the relation is "gte" (greater than or equal). You can increase that number using the ep_max_results_window filter but that can come with a performance penalty. The plugin should probably change that to show +10,000 items though. Do you mind opening a separate issue with that?
  4. Which query are you referring to? Although ES is fast, it is not guaranteed that it will always be faster than MySQL.

Regarding donating, although you can use the donate button on this page that is really not expected from our users :) Thanks!

Hi @felipeelia

  1. ep_set_sort to achieve post__in target ?
  2. I will open new ticket and we can discuss there but on first ball it looks like some kind of issue :)
  3. When you open wp-admin page it check for no of unpublished comments so it display no of count here in admin side panel

@felipeelia
Copy link
Member

Hey @dnikola ,

  1. No, to use the unmapped_type and avoid getting an error. It won't help you much though, as it solely won't give you post__in support, unfortunately.
  2. Great, I'll be looking forward to that ticket
  3. Sorry, it is still not clear to me. Do you mind explaining it further?

Thanks!

@github-actions
Copy link

This issue has been automatically closed because there has been no response to our request for more information. With only the information that is currently in the issue, we don't have enough information to take action. Please reach out if you have or find the answers we need so that we can investigate further. See this blog post on bug reports and the importance of repro steps for more information about the kind of information that may be helpful.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants