File not found when attempting to index

Hello. I'm building a simple elasticsearch/PHP application, and I got a very weird error. I can search on it just fine, though I need to build pagination for it still, but when I attempt to index something, I simply get a "File not found" error. I'm using a CSV to store the data, and it's been working fine so far, but I can't insert any data.

$postData = $es->index([
      'index' => 'books',
      'type' => '_doc',
      'body' => [
         'Book_title' => $Book_title,
         'Description' => $Description,
  	     'Number_Of_Pages' => $Number_Of_Pages,
  	     'Price' => $Price,
  	     'Rating' => $Rating,
  	     'Reviews' => $Reviews,
  	     'Type' => $Type
      ]  
  	]);

Anyone willing to share thoughts on it? Thank you in advance for your time.

There's barely nothing that could help us to help you here.

File not found

Well, this seems to be a local message when you read your file and not related to Elasticsearch IMO.

But if you can share:

  • The full error
  • The full code

We might be able to help.

Honestly, that's the biggest issue, I can't get the error logs. Spent all day trying to set up Filebeats or something to get it and that's going nowhere (seemingly issues with running on Windows Powershell, I always eventually run into some command that Windows doesn't recognize). I can send the full code, though.

<?php
require_once 'init.php';
if(!empty($_POST)){
  if(isset($_POST['Book_title'], $_POST['Description'], $_POST['Number_Of_Pages'], $_POST['Price'], $_POST['Rating'], $_POST['Reviews'], $_POST['Type'])){
  	$Book_title = $_POST['Book_title'];
  	$Description = $_POST['Description'];
  	$Number_Of_Pages = $_POST['Number_Of_Pages'];
  	$Price = $_POST['Price'];
  	$Rating = $_POST['Rating'];
  	$Reviews = $_POST['Reviews'];
  	$Type = $_POST['Type'];
  	$postData = $es->index([
      'index' => 'books',
      'type' => '_doc',
      'body' => [
         'Book_title' => $Book_title,
         'Description' => $Description,
  	     'Number_Of_Pages' => $Number_Of_Pages,
  	     'Price' => $Price,
  	     'Rating' => $Rating,
  	     'Reviews' => $Reviews,
  	     'Type' => $Type
      ]  
  	]);
    if($postData){
      echo '<div class="alert" role="alert"> Documento inserido com sucesso. </div>';
    }
  }
}
?>
<!DOCTYPE html>
<html>
<head>
  <title>Inserir dados:</title>
  <link rel="stylesheet" href="estilo.css">
</head>
<body>
 <form action="admin.php" method="post" autocomplete="off">
  <label> Insira dados do livro: <br><br>
    <input type="text" name="Book_title" placeholder="Título do livro:"><br><br>
    <textarea name="Description" rows="8" placeholder="Descreva o livro:"></textarea> <br><br>
    <input type="int" name="Number_Of_Pages" placeholder="Número de paginas:"><br><br>
    <input type="float" name="Price" placeholder="Preço:"><br><br>
    <input type="float" name="Rating" placeholder="Pontuação:"><br><br>
    <input type="int" name="Reviews" placeholder="Número de reviews:"><br><br>
    <input type="text" name="Type" placeholder="Encadernamento"><br><br>
  </label>
  <input type="submit" value="Inserir">
  </form> 
</body>
</html>

As you can see, very, very basic. As for the init.php...

<?php
require_once __DIR__ . '/vendor/autoload.php';
use Elasticsearch\ClientBuilder;
$es = Clientbuilder::create()->setHosts(['http://es01:9200'])->build();

Hope this is enough? Gonna keep trying to set up filebeats so I can see error logs, but frankly I have no idea how I'll manage to do that. A problem at a time, I suppose.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.