• This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn more.

Generic 'range' search

Xon

Well-known member
#1
Currently (XF1 & XF2) search only supports set-based matching, and not range operators (>=, <=, etc) for non-date type searching.

Both MySQL and ElasticSearch support types of range operators and such, and it would be nice for this to be surfaced for add-on authors or other search terms. This would allow removing the special case for date-range searches
 

Mike

XenForo developer
Staff member
#2
Aside from dates, what ranges are you referring to? Particularly, what ranges would work within the xf_search_index table other than date? Any metadata ranges wouldn't short of flipping to a query constraint instead.
 

Alfa1

Well-known member
#3
I'm not 100% sure if this is related, but one thing that I have been wanting is range search for custom fields. So that we can search for all threads/items that have a value in custom field X between 3 and 7.
I have frequently encountered the need for this in addons.
 

Xon

Well-known member
#4
Aside from dates, what ranges are you referring to? Particularly, what ranges would work within the xf_search_index table other than date? Any metadata ranges wouldn't short of flipping to a query constraint instead.
My particular use-case is pushing word-count into the search index, but with custom fields now common adding search support for ranges based on numerical custom field values would be very easy to-do with ElasticSearch.

The use of query constraints means the full-query can't be used into ElasticSearch and means over-fetching. At least not without rewriting the query constraint into an elastic search metadata constrain, except the query constraint doesn't have enough structured information to-do that.

It would actually be nice to split up the SqlConstraint\SqlQuery so the "condition" was split into an operation and identifier. This would make this much easier.
 
Last edited:

Mike

XenForo developer
Staff member
#5
Right, I was mostly trying to clarify this part:
Both MySQL and ElasticSearch support types of range operators and such
As in this instance it's not something that would be supported in MySQL (without using a different approach).
 

Xon

Well-known member
#6
As in this instance it's not something that would be supported in MySQL (without using a different approach).
MySQL would support it as an SqlConstraint, but this doesn't work for Elastic Search.

This is actually something of a step back going from XF1 -> XF2 where XF2 effectively writes an SQL query fragment at a high-level into the query object rather than easily analyzable components.