yawik / Solr

This YAWIK module enables solr search for job openings.
http://jobs.yawik.org
MIT License
1 stars 2 forks source link

Add configurable default filter queries #18

Closed TiSiE closed 5 years ago

TiSiE commented 5 years ago

It should be possible to configure default filter queries which are used for every search request regardless of user input via the search form.

Solr provides the ability to define such filter queries so we should use this. All we have to do is:

kilip commented 5 years ago

Hello @TiSiE,

I am still confusing where to actually put this default filter query. Do you want this line 69 and 71 to be configurable?

https://github.com/yawik/Solr/blob/d5f70b54d65d77d9867d9b3624cf397b904f463f/src/Filter/JobBoardPaginationQuery.php#L51-L72

cbleek commented 5 years ago

That's a great idea. Lets make these lines configurable.

cbleek commented 5 years ago

We have the following UseCase.

2 YAWIK installations use a shared Solr index. The installations should make only a subset of the Solr searchable.

One installation, for example, only provides job advertisements from Germany. The other only advertisements of certain companies.

so one installation can cofigure

fiterQuery=[ 'entityName:job', 'isActive:1', 'fieldXY:mysubset' ]

$fiels=[ '*' ]

In case of a spatial search, the filterQuery is more complicated. But it' possible to define.

kilip commented 5 years ago

@TiSiE , @cbleek

I try to implementing filter queries by adding new filterQueries options. This values will accept an array list of string/callable values. The configuration for this filterQueries options will be like:

$options = [
  "filterQueries" => [
     "entityName:job",
     // ... other string value or:
     function(SolrDisMaxQuery $query){
        $query->addFilterQuery('some-filter');
     }
  ]
];
return [ 'options' => [ 'Solr/Options/Module' => [ 'options' => $options ] ] ];

Please let me know if there are any suggestion for implementing this configurable filter queries.