floriansemm / SolrBundle

Solr-Integration into Symfony and Doctrine2
http://floriansemm.github.io/SolrBundle
MIT License
123 stars 72 forks source link

Filter queries lost during select function #110

Closed fliespl closed 9 years ago

fliespl commented 9 years ago

As in the topic, when using $query->getResult(); filter queries are being stripped.

This is because of the creation of new Query object in query method.

        $queryString = $query->getQuery();
        $runQueryInIndex = $query->getIndex();
        $query = $this->solrClientCore->createSelect($query->getOptions()); // filter queries lost here
        $query->setQuery($queryString);

Sample code:

            $query = $this->get('solr.client')->createQuery($cls);
            $query->setRows(3);
            $query->addSearchTerm('title', $request->get('fraza'));
            $fq = $query->createFilterQuery('year')->setQuery('year:[2000 TO 2005]');
            $query->addFilterQuery($fq);

            $result = $query->getResult();

Resulting query is:

omitHeader=true&fl=&start=0&q=title_s:*qui*&json.nl=flat&wt=json&rows=3
fliespl commented 9 years ago

I think it's not resolved in this commit.

It seems that $selectQuery is not used after all during query.

floriansemm commented 9 years ago

fixed in c5f2f7fbb017200750d28392b0858982f982c41b