Implemented Allow better extendability in XF2 search

Xon

Well-known member
I'm trying to work at extending the search subsystem, and I'm running into roadblocks that the two core classes; XF\Search\Search && XF\Search\Query\Query aren't extendable.

My primary desire is to be able to transform a MetadataConstraint into something else later (as implementing a range query for MySQL is different to ElasticSearch). This requires being able to manipulate the Query object, which is mostly write-once.

I've got a fairly horrible hack which semi-works, but in XF1 the XF\Search\Search equivalent was extendable.
 
Upvote 5
This suggestion has been implemented. Votes are no longer accepted.
I've made the query object extendable as I can see benefits in allowing more functionality in that.

However, what's the specific use case to extending the Search class? For the most part, it actually just wraps calls to other objects. Saying that, there isn't harm in allowing it to be extended.
 
The original requirement is to be able to rewrite the contents of the metadataConstraints protected variable to support the ranged query against an injected word-count column on the xf_search_index table.

Currently I'm using a hack where I derive from a class from \XF\Search\Query\Query, and which implement a static member to set the protected variable of a \XF\Search\Query\Query instance. See; https://github.com/Xon/XenForo2-Wor...ntSearch/XF/Search/Source/MySqlFt.php#L67-L90
 
Back
Top Bottom