floriansemm / SolrBundle

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

Problem with filter query Paramater #148

Closed muganda closed 7 years ago

muganda commented 8 years ago

Hi.... Whenever i try to do a search i don't get back any result. After some research i have discovered that the issue has to do with the paramater fq=id:book* that is added on each query i make. I know that "book" comes from the entity that am searching (which is named book) but what i don't understand is why it adds that in the first place and why the prefix "book" When i check the solr logs i see this q=:&json.nl=flat&omitHeader=true&fl=&start=0&fq=id:book_&rows=10&wt=json And whenever i try that in the browser with out including "fq=id:book" or changing it to "fq=id:" then i get back the results fine.

What can i do to get the results desired?

Thanks for your help

floriansemm commented 8 years ago

An collection/index can contain more then one type of documents, e.g.: Books and Authors. Each document has a field id which is unique. If you index a book and author entity with the same id, then one entity will be overwritten. To avoid that all ids are prefixed with their type.

In your query q=:&json.nl=flat&omitHeader=true&fl=&start=0&fq=id:book_&rows=10&wt=json is the q-parameter wrong. The value must be something like q=*:*.

Change fq=id:book to fq=id:book_* and you will get some documents.

muganda commented 8 years ago

In my case the problem was not about the q paramater but rather the fq parameter. No matter what i did the query that was being sent to Solr always have this

fq=id:book_*

I never sent that anywhere but it was always there regardles of what i did. I know it comes from the core configuration (since what am searching for is a book. I suspect if in the core configuration i had say 'mybook' it would still add fq=id:mybook_). So my question of why it always adds a query filter and how i can either tell it not to add it or add something else (e.g. fq=id:).

On 11/14/2016 11:05 AM, Florian Semm wrote:

An collection/index can contain more then one type of documents, e.g.: Books and Authors. Each document has a field |id| which is unique. If you index a book and author entity with the same id, then one entity will be overwritten. To avoid that all ids are prefixed with their type.

In your query |q=:&json.nl=flat&omitHeader=true&fl=&start=0&fq=id:book&rows=10&wt=json| is the q-parameter wrong. The value must be something like |q=:_|.

Change |fq=id:book| to |fq=id:book_*| and you will get some documents.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/floriansemm/SolrBundle/issues/148#issuecomment-260271700, or mute the thread https://github.com/notifications/unsubscribe-auth/AMbcapWzEiGB3s7dhRrIHPoi8nOhlDL_ks5q-BZYgaJpZM4KwKUC.

floriansemm commented 8 years ago

the fq id:mybook_* was in an older version of this bundle part of the q. Filter queries are made to restrict a subset of documents.

To remove the filter query:

$query = $this->solr->createQuery('Your:Entity');
$query->removeFilterQuery('id');
$result = $query->getResult();