Hi,
I have various sliders for filtering results, some for decimal fields and others for integer fields. i will explain my problem with an example:
I have an integer field (number of rooms) in my content type. I have set a range filter for that field. When I see the results, I have results with, let's say, 3 rooms. Then I set the slider to the values "0 TO 3". The results dont't display the nodes with 7 rooms, but it displays the results with 0 rooms.
The behavior of "0 TO 3" should be (I think) showing the nodes that have at least 0 rooms and at most 3 rooms, both included. Min Value <= X <= Max Value. Now the behavior is: Min <= X < Max.
I have attatched 2 screenshots to help.
Thanks!!
| Comment | File | Size | Author |
|---|---|---|---|
| after.jpg | 127.49 KB | jordiserra | |
| before.jpg | 132.09 KB | jordiserra |
Comments
Comment #1
Anonymous (not verified) commentedHi, it's the way Search API / Facet API works, e.g. ?f[0]=rooms:[0 TO 4]
[0 TO 4] results in "Min <= X < Max"
I don't know what to do about that.
Comment #2
jordiserra commentedOk, but it's not intuitive at all; if somebody selects "0 TO 3" to filter something, expects to see results with values 0, 1, 2 and 3. I dont't understand the sense of this...
Thanks anyway for answer!!!
Comment #3
Anonymous (not verified) commentedWe'll have to ask Facet API for a solution. Postponing until we know more.
http://drupal.org/project/facetapi
If I remember correctly, this could be a solution:
?f[0]=rooms:[0 TO 3*
Can you try with that * instead of ]? What happens then? Maybe this is the solution.
Comment #4
jordiserra commentedI recieve a 500 internal error! :(
I tried a lot of symbols instead of ], but i recieve the same error every time.
Comment #5
Anonymous (not verified) commentedI think in English language the phrase "1 to 5" means 1,2,3 and 4. Otherwise it would say "up to and including 5". So it's kind of intuitive for native English speakers.
On the other hand, there is reason to expect a consistent
A <= X <= B. But the "problem" is in the Facet API logic, where it translate the value mapping [A TO B] into$map[$value] = "$lower – $upper";. This is in search_api_facetapi.module line 313, which eventually becomesA <= X < B.So I'm closing this thread (it's not related to Search API ranges). But you can open a new issue for either Search API facetapi or Facet API.
Comment #6
jordiserra commentedFound it!
In the file search_api_facetapi/plugins/facetapi/query_type_term.inc line 89:
$query_filter->condition($field, $upper, '<');
changed to
$query_filter->condition($field, $upper, '<=');
and just works as I wanted!
Nevertheless, I will propose that in search api facetapi, I think it should be at least an option to configure, because not every world have the intuition of english speakers! ;)
Comment #7
Anonymous (not verified) commentedHey great! Ok, I hope your patch will be accepted.
Comment #8
Anonymous (not verified) commentedSetting this to fixed. See solution in #6 which belongs in Search API facetapi.
Comment #10
nbucknor commentedI couldn't find jordiserra's patch anywhere in the Search API issue queue, so I added one myself. http://drupal.org/node/1363114