# File not found when attempting to index

**URL:** <https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353>\
**Category:** Elasticsearch\
**Created:** [October 4, 2023, 3:15am UTC](https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353 "2023-10-04T03:15:42Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ahriss](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Ahriss](https://discuss.elastic.co/u/Ahriss)\
**Post date:** [October 4, 2023, 3:15am UTC](https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353/1 "2023-10-04T03:15:42Z")

</div>

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.

```auto
$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.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 4, 2023, 7:36am UTC](https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353/2 "2023-10-04T07:36:31Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Ahriss](https://avatars.discourse-cdn.com/v4/letter/a/e274bd/32.png) [@Ahriss](https://discuss.elastic.co/u/Ahriss)\
**Post date:** [October 4, 2023, 7:23pm UTC](https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353/3 "2023-10-04T19:23:12Z")

</div>

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.

```auto
<?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...

```auto
<?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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 1, 2023, 7:23pm UTC](https://discuss.elastic.co/t/file-not-found-when-attempting-to-index/344353/4 "2023-11-01T19:23:25Z")

</div>

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