How to range search, on a value range

This is actually two or three questions. They may be the wrong questions, so if there’s reasons for not doing it this way please share!

1. How to range search by entering a minimum and maximum value?
A user wants to filter the query to only include values that fit within the entered minimum and maximum value.

2. How to range search on a metadata range value?
That is, to find any documents that that have a range that intersects with the query range.
Eg: I search for “2-5”, and the following results are returned:

  • 2-2
  • 1-2
  • 3-6
  • 3-4

Hi David,

You’ll need a numeric metadata field containing the item’s value (eg. price=54)

Once you’ve got that defined you can make use of the numeric operators that are available for numeric metadata fields:

Funnelback 15.14+ Metadata class types - Funnelback Documentation - Version 15.14.0
Funnelabck 15.12 and earlier: Numerical metadata - Funnelback Documentation - Version 15.12.0

Also, you can produce facets that cover the desired ranges. Take a look at numeric range facets:
Funnelback 15.12+: Facet categories - Funnelback Documentation - Version 15.14.0
Funnelback 15.10 and earlier: Redirect Notice

Thanks Peter, so as far as I can see:

For question one the answer is to have an input field for a le param and ge param.

But for question two it’s not possible. I think it might be possible to write a groovy script to process the entire data set and produce occurrences for each interval (like event mode), then search with le and ge on that.

But thankfully the client is happy to not have this functionality after all :wink:

For question one - yes, but the metadata field must be a numeric type field and contain a numeric value.

For question two it would be a bit complicated to achieve - and would require a bit of thought to come up with something that worked.

For question two, could you instead write a script that would give another metadata value containing a list or sequence of multiple values, equal to the integers between and including the lower and upper bounds of the range.

e.g. for the results you mentioned, they would have a corresponding field with the following values:

2-2 = 2
1-2 = 1|2
3-6 = 3|4|5|6
3-4 = 3|4

And then you just need to use numeric range facets as @plevan mentioned.

My knowledge of groovy isn’t that great, so I don’t know the actual code to produce those values, but I’m sure it’s possible with simple loops.

1 Like