使用Elasticsearch在Laravel中搜索查询的逻辑

I am using Laravel together with Elasticsearch in order to search an table/type.

I have a total of 5 search filters that a user can use in order to search.

Title(string) - type(boolean) - state name(int) - city name(int) - price(int)

So the query can have 31 different combinations.

Since I cant use something like Eloquent ORM here I need to write each query for ES.

Is there a better way to do this?

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.

'filtered' => [
                'query' => [
                    'match' => ['title' => Input::get('query')]
                ],
                'filter'=> [
                    'bool' => [
                        'must' => [
                            ['term' => [ 'type' =>  1] ],
                            ['term' => [ 'state' =>  22] ],
                            ['term' => [ 'city' => ] ],
                            [ 'range' => [
                                    'price' => [
                                        'gte' => ,
                                        'lte' => ,
                                    ]
                                ]
                            ]
                        ]
                    ]
                ],
            ],

Have you seen Elastica?

http://elastica.io/example/aggregations/terms.html

This might be the closest you will get to something that provides an Eloquent-like interface to Elasticsearch.

use Elastica\Aggregation\Terms;
use Elastica\Query;

// set up the aggregation
$termsAgg = new Terms("genders");
$termsAgg->setField("gender");
$termsAgg->setSize(10);

// add the aggregation to a Query object
$query = new Query();
$query->addAggregation($termsAgg);

// retrieve the results
$index = $elasticaClient->getIndex('someindex');
$buckets = $index->search($query)->getAggregation("genders");

Which will end up building a query like:

{
    "aggs" : {
        "genders" : {
            "terms" : { "field" : "gender" },
            "size": 10
        }
    }
}