I was trying to workout the example from the below link
Search Engine with PHP & Elasticsearch - YouTube
<https://www.youtube.com/watch?v=3xb1dHLg-Lk>
I cannot index the document (add.php example).
only When I remove the code for the Indexing the html form appears.
<?php
require 'vendor/autoload.php';
$es = new Elasticsearch\Client();
if(!empty($_POST)) {
if(isset($_POST['title'],$_POST['body'],$_POST['keywords'])) {
$title = $_POST['title'];
$body = $_POST['body'];
$keywords = explode(',',$_POST['keywords']);
$indexed = $es->index([
'index' => 'articles',
'type' => 'article',
'body' => [
'title' => $title,
'body' => $body,
'keywords' => $keywords
]
]);
if($indexed) {
print_r($indexed)
}
}
}
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>Add in ES</title>
<link rel="stylesheet">
</head>
<body>
<form action="add.php" method="post" autocomplete="off">
<label>
Title
<input type="text" name="title">
</label>
<br>
<br><br>
<label>
Body
<textarea name="body" rows="8"></textarea>
</label>
<br><br><br>
<label>
Keywords
<input type="text" name="keywords">
</label>
<br><br><br>
<input type="submit" value="search" value="Add">
</form>
</body>
</html>
Thanks in Advance
--
You received this message because you are subscribed to the Google Groups
"elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/elasticsearch/71680616-7733-4244-a78e-6342013d2564%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.