Note that there are some explanatory texts on larger screens.

plurals
  1. POSearch Box in Symfony2 with Solr
    primarykey
    data
    text
    <p>I want to create <em>Search box</em> in front page of my website but I don't know how to create one using <em>Solr</em>. All my website is developed in <strong>Symfony2</strong>. I don't use Database for searching.</p> <p>How I can do this?.</p> <p>In my project <em>Solr</em> bundle use this:</p> <pre><code>use SolrClient; use SolrQuery; use SolrObject; use SolrDocument; use SolrInputDocument; </code></pre> <p>In base <em>twig</em> file : </p> <pre><code>&lt;form action="{{ path("home_search") }}" method="get"&gt; &lt;input type="search" name="search"&gt;&lt;br&gt; &lt;input type="submit" value="search"&gt; &lt;/form&gt; </code></pre> <p>Some example of my controller:</p> <pre><code>public function searchAction($templateName = '') { $solrService = $this-&gt;get('rocket.solr_service'); $solrQuery = new SolrQuery('*:*'); $solrQuery-&gt;addField('id') -&gt;addField('name'); if (!empty($templateName)) { $solrQuery-&gt;addFilterQuery(sprintf('name:"%s" OR design_template_tag_name:"%1$s" OR design_category_name:"%1$s"', $templateName)); } $solrQuery-&gt;setRows(1000); $solrObject = $solrService-&gt;query( 'RocketBraPrintBundle:DesignTemplate', $solrQuery, SolrService::WRITER_FORMAT_SOLR_OBJECT ); $templates = $solrObject-&gt;offsetGet('response')-&gt;offsetGet('docs'); if (!$templates) { if (!empty($templateName)) { $this-&gt;setFlash('catalog-message', 'No results found for your search.'); return $this-&gt;searchDesignTemplates($categoryTreeSlug, $productFamilyFaceId); } return array(); } return $templates; } </code></pre> <p>But in twig file where this is render I don't know what I will write. </p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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