I have a very large taxonomy vocabulary with numeric taxonomy term names like: 10123,10124,10125,... etc. My node have a min value field and max value field. Both fields are taxonomy referenced fields with this vocabulary. How I can create views filter to find a nodes, where exposed filter value is between these two fields?

Example 1.

  • Node field min: Taxonomy term with name "10500"
  • Node field max:Taxonomy term with name "11000"
  • Exposed filter value: 10800

This is TRUE, so this node must be in views result.

Example 1.

  • Node field min: Taxonomy term with name "10500"
  • Node field max: Taxonomy term with name "11000"
  • Exposed filter value: 11500

This is FALSE, so this node should not be in views result.

Exposed filter value can be as taxonomy term autocomplete widget.

Any ideas, how it can realize?

I'm looking a solution in _views_query_alter, but I still can not understand is this right way?..

  • 1
    I'd just add an integer field and use rules to fill it on node add or update with the node's term's field name. Then use that as the filter. (This isn't good advice.. It's more of a last resort that would work.) Aug 13, 2018 at 15:22

1 Answer 1


I believe a numeric range can be filtered using regular expression.

The following regex can effectively filter values within the range 10500 - 11000 (both ends inclusive)


Here is a sample view that works as expected with the above regular expression

enter image description here

You can create any numeric range as a regex using this generator http://gamon.webfactional.com/regexnumericrangegenerator/

Alternativelly what you can do is to add an extra numeric field to populate with term name (as a number) and than using that field to filter the view OR create a more complex function using hook_views_query_alter as you mentioned

  • Thank you! Did by adding extra numeric field. It's faster solution, for this moment it's suitable for me.
    – Viktor
    Aug 15, 2018 at 7:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.