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!!

CommentFileSizeAuthor
after.jpg127.49 KBjordiserra
before.jpg132.09 KBjordiserra

Comments

Anonymous’s picture

Hi, 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.

jordiserra’s picture

Ok, 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!!!

Anonymous’s picture

Status: Active » Postponed

We'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.

jordiserra’s picture

I recieve a 500 internal error! :(

I tried a lot of symbols instead of ], but i recieve the same error every time.

Anonymous’s picture

Status: Postponed » Closed (works as designed)

I 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 becomes A <= 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.

jordiserra’s picture

Status: Closed (works as designed) » Postponed

Found 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! ;)

Anonymous’s picture

Hey great! Ok, I hope your patch will be accepted.

Anonymous’s picture

Status: Postponed » Fixed

Setting this to fixed. See solution in #6 which belongs in Search API facetapi.

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

nbucknor’s picture

I couldn't find jordiserra's patch anywhere in the Search API issue queue, so I added one myself. http://drupal.org/node/1363114