ezfind icon indicating copy to clipboard operation
ezfind copied to clipboard

EZP-26630: Support per-query raw filters

Open peterkeung opened this issue 8 years ago • 9 comments

https://jira.ez.no/browse/EZP-26630

In eZ Find, all filters expect to follow the pattern field:value. If you don't have a colon, ezfeZPSolrQueryBuilder::getParamFilterQuery() prepends a colon, effectively breaking some filters. This prevents you from adding special filters for the "fq" parameter in Solr, such as frange queries:

http://solr.pl/en/2011/05/30/quick-look-frange/

An example use case is to enforce a minimum relevance score:

{!frange l=1}query({!edismax v=$q})

You can get around this by using RawFilterList in ezfind.ini, but that's applied to every query.

This proposed solution would add a new parameter "raw_filter" to the ezfind/search fetch function:

'raw_filter', array( '{!frange l=1\}query({!edismax v=$q\})' ),

peterkeung avatar Nov 19 '16 07:11 peterkeung

Ping @moismailzai @benkmugo

peterkeung avatar Nov 19 '16 07:11 peterkeung

+1 this looks good to me.

I can confirm this patch is functional and works well in practice (that is, the filter range is limiting results as expected).

moismailzai avatar Nov 21 '16 17:11 moismailzai

The flexibility this adds is a good improvement I think. It avoids having to use workarounds or going via the raw solr fetch in template land.

+1

benkmugo avatar Nov 21 '16 23:11 benkmugo

+1 (apart from remark)

gggeek avatar Nov 26 '17 14:11 gggeek

I don't like that the parameters filter and raw_filter take an array for the value. I think it will combine multiple array elements with a logical AND. That's something not very obvious for a developer. But that's how the parameter filter was developed and raw_filter is now consistent to that approach - so I'm OK with it. Maybe we add inline doc saying something about how multiple array entries are handled.

+1

pkamps avatar Dec 14 '17 11:12 pkamps

I think adding a brief inline doc note about those two parameter values would be a good idea.

benkmugo avatar Dec 14 '17 21:12 benkmugo

@pkamps @benkmugo I've added additional comments where the filters are built

peterkeung avatar Dec 22 '17 15:12 peterkeung

+1

benkmugo avatar Jan 01 '18 22:01 benkmugo

Let's get this merged!

peterkeung avatar Mar 18 '18 22:03 peterkeung