Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>CRON jobs wouldn't apply unless you would want to schedule the searches and notify your users when the search is done (even though it's possible, it's not really what you're looking for).</p> <p>AJAX is quite handy here especially if you'd like to add such functionality as autocompletion. However if you're expecting the page to reload, re-rendering the whole page contents with the search results or redirecting to another page with those results, AJAX isn't necessary, because you'd have to do 2 HTTP requests rather than just one.</p> <p>In my opinion, all you need to do is have a single-input form with the search field posting via a GET request.</p> <p>So for instance:</p> <pre><code>&lt;form action="/search_results.php" method="get"&gt; &lt;input type="text" name="query" /&gt; &lt;button type="submit"&gt;Search&lt;/button&gt; &lt;/form&gt; </code></pre> <p>Which would do a redirect to the search results page with the URL as something like this: /search_results.php?query=some+simple+search</p> <p>Then, within your PHP code you can fetch that query parameter using $_GET['query'] which you can directly pass to your search engine (Elastic Search) to analyse.</p> <p>I haven't ever tried Elastic Search, but if you must pass JSON data, you can just encode the query using:</p> <pre><code>$search = json_encode(array('query' =&gt; $_GET['query'])); </code></pre> <p>It's hard to be precise because you haven't provided the expected format for the search, but I think this should get you on track.</p> <p>Feel free to comment below if you have any questions :)</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload