Why my code does not index all posts correctly?PHP + curl, HTTP POST sample code?Why doesn't this code simply print letters A to Z?Wordpress query from Magento/WHMCS return wrong resultWordpress claiming admin user ID as author for all postsWordPress custom post type pagination links return 404Getting ID from get_posts within a loop in WordpressAlgolia WordPress Plugin Wont Process Index Cueuecustom post_type - changing the posts_per_page - not working correctlyGet image post by taxonomy/category wordpressWordpress Algolia plugin, only indexes all posts into searchable_posts index, rather than enabled ones?

It is as easy as A B C, Figure out U V C from the given relationship

Is there any deeper thematic meaning to the white horse that Arya finds in The Bells (S08E05)?

Could a space colony 1g from the sun work?

Understanding Deutch's Algorithm

UUID type for NEWID()

How to describe a building set which is like LEGO without using the "LEGO" word?

Would life always name the light from their sun "white"

What is the status of the Lannisters after Season 8 Episode 5, "The Bells"?

To whom did Varys write those letters in Game of Thrones S8E5?

Is the seat-belt sign activation when a pilot goes to the lavatory standard procedure?

Is there any good reason to write "it is easy to see"?

How to rename multiple files in a directory at the same time

Formal Definition of Dot Product

When did game consoles begin including FPUs?

With today's technology, could iron be smelted at La Rinconada?

Does this "yield your space to an ally" rule my 3.5 group uses appear anywhere in the official rules?

Promotion comes with unexpected 24/7/365 on-call

Can my American children re-enter the USA by International flight with a passport card? Being that their passport book has expired

What is the effect of the Feeblemind spell on Ability Score Improvements?

Why would company (decision makers) wait for someone to retire, rather than lay them off, when their role is no longer needed?

What was Varys trying to do at the beginning of S08E05?

Why did the soldiers of the North disobey Jon?

Why is the Advance Variation considered strong vs the Caro-Kann but not vs the Scandinavian?

Assembly writer vs compiler



Why my code does not index all posts correctly?


PHP + curl, HTTP POST sample code?Why doesn't this code simply print letters A to Z?Wordpress query from Magento/WHMCS return wrong resultWordpress claiming admin user ID as author for all postsWordPress custom post type pagination links return 404Getting ID from get_posts within a loop in WordpressAlgolia WordPress Plugin Wont Process Index Cueuecustom post_type - changing the posts_per_page - not working correctlyGet image post by taxonomy/category wordpressWordpress Algolia plugin, only indexes all posts into searchable_posts index, rather than enabled ones?






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty height:90px;width:728px;box-sizing:border-box;








0















I have more than 600,000 posts to be indexed by Algolia (Wordpress based), so I wrote a "reindex_post" command to enable all my posts indexed batch by batch to avoid memory used up. However, when I use this command in WP-CLI, some posts seem not to be indexed correctly and I found two errors:



  1. Some posts can't be searched from my front end though I can see it at the back end of Algolia.


  2. When I enter more than 3 characters in my front end, autocomplete does not work though it works when I enter less than 3 characters.


I installed the Algolia wordpress plugin and tried using it index my posts and found that it works well. None of the two problems below happened. The only problem is I can't index 600,000 posts by this way.



public function reindex_post($args, $assoc_args)



 $start = 0;
$end = 0;
if (count($args) === 1)
$arr = explode(',', $args[0]);
$start = intval($arr[0]);
$end = intval($arr[1]);
echo "鍚姩鍒嗛〉锛?start->$endn";

global $algolia;
$index = $algolia->initIndex('wp_searchable_posts');
$paged = $start;
$count = 0;
do

$posts = new WP_Query([
'posts_per_page' => 50,
'paged' => $paged,
'post_type' => 'post'
]);

if (!$posts->have_posts())
break;


$records = [];
foreach ($posts->posts as $post)
if ($assoc_args['verbose'])
WP_CLI::line('Serializing [' . $post->post_title . ']');

$record = (array)apply_filters('post_to_record', $post);

if (!isset($record['objectID']))
$record['objectID'] = implode('#', [$post->post_type, $post->ID]);


$records[] = $record;
$count++;


if ($assoc_args['verbose'])
WP_CLI::line('Sending batch');

$index->saveObjects($records);

$paged++;
if ($paged > $end)
break;

while (true);

WP_CLI::success("$count posts indexed in Algolia");



}



I'm a new programmer and not very familiar with php. I would highly appreciate it if some one can tell me how to modify it exactly










share|improve this question






























    0















    I have more than 600,000 posts to be indexed by Algolia (Wordpress based), so I wrote a "reindex_post" command to enable all my posts indexed batch by batch to avoid memory used up. However, when I use this command in WP-CLI, some posts seem not to be indexed correctly and I found two errors:



    1. Some posts can't be searched from my front end though I can see it at the back end of Algolia.


    2. When I enter more than 3 characters in my front end, autocomplete does not work though it works when I enter less than 3 characters.


    I installed the Algolia wordpress plugin and tried using it index my posts and found that it works well. None of the two problems below happened. The only problem is I can't index 600,000 posts by this way.



    public function reindex_post($args, $assoc_args)



     $start = 0;
    $end = 0;
    if (count($args) === 1)
    $arr = explode(',', $args[0]);
    $start = intval($arr[0]);
    $end = intval($arr[1]);
    echo "鍚姩鍒嗛〉锛?start->$endn";

    global $algolia;
    $index = $algolia->initIndex('wp_searchable_posts');
    $paged = $start;
    $count = 0;
    do

    $posts = new WP_Query([
    'posts_per_page' => 50,
    'paged' => $paged,
    'post_type' => 'post'
    ]);

    if (!$posts->have_posts())
    break;


    $records = [];
    foreach ($posts->posts as $post)
    if ($assoc_args['verbose'])
    WP_CLI::line('Serializing [' . $post->post_title . ']');

    $record = (array)apply_filters('post_to_record', $post);

    if (!isset($record['objectID']))
    $record['objectID'] = implode('#', [$post->post_type, $post->ID]);


    $records[] = $record;
    $count++;


    if ($assoc_args['verbose'])
    WP_CLI::line('Sending batch');

    $index->saveObjects($records);

    $paged++;
    if ($paged > $end)
    break;

    while (true);

    WP_CLI::success("$count posts indexed in Algolia");



    }



    I'm a new programmer and not very familiar with php. I would highly appreciate it if some one can tell me how to modify it exactly










    share|improve this question


























      0












      0








      0








      I have more than 600,000 posts to be indexed by Algolia (Wordpress based), so I wrote a "reindex_post" command to enable all my posts indexed batch by batch to avoid memory used up. However, when I use this command in WP-CLI, some posts seem not to be indexed correctly and I found two errors:



      1. Some posts can't be searched from my front end though I can see it at the back end of Algolia.


      2. When I enter more than 3 characters in my front end, autocomplete does not work though it works when I enter less than 3 characters.


      I installed the Algolia wordpress plugin and tried using it index my posts and found that it works well. None of the two problems below happened. The only problem is I can't index 600,000 posts by this way.



      public function reindex_post($args, $assoc_args)



       $start = 0;
      $end = 0;
      if (count($args) === 1)
      $arr = explode(',', $args[0]);
      $start = intval($arr[0]);
      $end = intval($arr[1]);
      echo "鍚姩鍒嗛〉锛?start->$endn";

      global $algolia;
      $index = $algolia->initIndex('wp_searchable_posts');
      $paged = $start;
      $count = 0;
      do

      $posts = new WP_Query([
      'posts_per_page' => 50,
      'paged' => $paged,
      'post_type' => 'post'
      ]);

      if (!$posts->have_posts())
      break;


      $records = [];
      foreach ($posts->posts as $post)
      if ($assoc_args['verbose'])
      WP_CLI::line('Serializing [' . $post->post_title . ']');

      $record = (array)apply_filters('post_to_record', $post);

      if (!isset($record['objectID']))
      $record['objectID'] = implode('#', [$post->post_type, $post->ID]);


      $records[] = $record;
      $count++;


      if ($assoc_args['verbose'])
      WP_CLI::line('Sending batch');

      $index->saveObjects($records);

      $paged++;
      if ($paged > $end)
      break;

      while (true);

      WP_CLI::success("$count posts indexed in Algolia");



      }



      I'm a new programmer and not very familiar with php. I would highly appreciate it if some one can tell me how to modify it exactly










      share|improve this question
















      I have more than 600,000 posts to be indexed by Algolia (Wordpress based), so I wrote a "reindex_post" command to enable all my posts indexed batch by batch to avoid memory used up. However, when I use this command in WP-CLI, some posts seem not to be indexed correctly and I found two errors:



      1. Some posts can't be searched from my front end though I can see it at the back end of Algolia.


      2. When I enter more than 3 characters in my front end, autocomplete does not work though it works when I enter less than 3 characters.


      I installed the Algolia wordpress plugin and tried using it index my posts and found that it works well. None of the two problems below happened. The only problem is I can't index 600,000 posts by this way.



      public function reindex_post($args, $assoc_args)



       $start = 0;
      $end = 0;
      if (count($args) === 1)
      $arr = explode(',', $args[0]);
      $start = intval($arr[0]);
      $end = intval($arr[1]);
      echo "鍚姩鍒嗛〉锛?start->$endn";

      global $algolia;
      $index = $algolia->initIndex('wp_searchable_posts');
      $paged = $start;
      $count = 0;
      do

      $posts = new WP_Query([
      'posts_per_page' => 50,
      'paged' => $paged,
      'post_type' => 'post'
      ]);

      if (!$posts->have_posts())
      break;


      $records = [];
      foreach ($posts->posts as $post)
      if ($assoc_args['verbose'])
      WP_CLI::line('Serializing [' . $post->post_title . ']');

      $record = (array)apply_filters('post_to_record', $post);

      if (!isset($record['objectID']))
      $record['objectID'] = implode('#', [$post->post_type, $post->ID]);


      $records[] = $record;
      $count++;


      if ($assoc_args['verbose'])
      WP_CLI::line('Sending batch');

      $index->saveObjects($records);

      $paged++;
      if ($paged > $end)
      break;

      while (true);

      WP_CLI::success("$count posts indexed in Algolia");



      }



      I'm a new programmer and not very familiar with php. I would highly appreciate it if some one can tell me how to modify it exactly







      php wordpress algolia






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 23 at 16:58









      Progman

      6,77232037




      6,77232037










      asked Mar 23 at 15:19









      GreatZhaoGreatZhao

      11




      11






















          0






          active

          oldest

          votes












          Your Answer






          StackExchange.ifUsing("editor", function ()
          StackExchange.using("externalEditor", function ()
          StackExchange.using("snippets", function ()
          StackExchange.snippets.init();
          );
          );
          , "code-snippets");

          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "1"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315245%2fwhy-my-code-does-not-index-all-posts-correctly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          0






          active

          oldest

          votes








          0






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Stack Overflow!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f55315245%2fwhy-my-code-does-not-index-all-posts-correctly%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          Kamusi Yaliyomo Aina za kamusi | Muundo wa kamusi | Faida za kamusi | Dhima ya picha katika kamusi | Marejeo | Tazama pia | Viungo vya nje | UrambazajiKuhusu kamusiGo-SwahiliWiki-KamusiKamusi ya Kiswahili na Kiingerezakuihariri na kuongeza habari

          SQL error code 1064 with creating Laravel foreign keysForeign key constraints: When to use ON UPDATE and ON DELETEDropping column with foreign key Laravel error: General error: 1025 Error on renameLaravel SQL Can't create tableLaravel Migration foreign key errorLaravel php artisan migrate:refresh giving a syntax errorSQLSTATE[42S01]: Base table or view already exists or Base table or view already exists: 1050 Tableerror in migrating laravel file to xampp serverSyntax error or access violation: 1064:syntax to use near 'unsigned not null, modelName varchar(191) not null, title varchar(191) not nLaravel cannot create new table field in mysqlLaravel 5.7:Last migration creates table but is not registered in the migration table

          은진 송씨 목차 역사 본관 분파 인물 조선 왕실과의 인척 관계 집성촌 항렬자 인구 같이 보기 각주 둘러보기 메뉴은진 송씨세종실록 149권, 지리지 충청도 공주목 은진현