title: Logic behind search query in Laravel using Elasticsearch
body: <p>I am using Laravel together with Elasticsearch in order to search an table/type.</p>
  
  <p>I have a total of 5 search filters that a user can use in order to search.</p>
  
  <p><strong>Title(string) - type(boolean) - state name(int) - city name(int) - price(int)</strong> </p>
  
  <p>So the query can have 31 different combinations.</p>
  
  <p>Since I cant use something like Eloquent ORM here I need to write each query for ES. </p>
  
  <p>Is there a better way to do this?</p>
  
  <p>Or is there some Laravel package that would let me do something like this - leave some search parameters empty and only let ES pick up those who arent empty.</p>
  
  <pre><code>'filtered' =&gt; [
                  'query' =&gt; [
                      'match' =&gt; ['title' =&gt; Input::get('query')]
                  ],
                  'filter'=&gt; [
                      'bool' =&gt; [
                          'must' =&gt; [
                              ['term' =&gt; [ 'type' =&gt;  1] ],
                              ['term' =&gt; [ 'state' =&gt;  22] ],
                              ['term' =&gt; [ 'city' =&gt; ] ],
                              [ 'range' =&gt; [
                                      'price' =&gt; [
                                          'gte' =&gt; ,
                                          'lte' =&gt; ,
                                      ]
                                  ]
                              ]
                          ]
                      ]
                  ],
              ],
  </code></pre>