Invision Community 4: SEO, prepare for v5 and dormant account notifications By Matt Monday at 02:04 PM
Martin A. Posted May 12, 2018 Posted May 12, 2018 In an app I'm developing I have the need to do a number range filtering on search results, for showing items where the price is between 100 and 200, for instance. Due to the insanely improved relevancy sorting you get by using Elastic over MySQL, we have to use Elastic. But how can I add my own data to the index? Looking at IPS\Content\Search\Elastic\Index::init(), that (as with the rest of the search classes) method does not offer an easy way to modify, only way is to duplicate the whole method in a hook. May I suggest two new indexes there? "index_extra_number" and "index_extra_string". Both for cases where 3rd party apps have a need to index additional data. I don't see any other way of doing this. Doing the filtering post-search, in the Results class, could cause a whole lot of other issues.
bfarber Posted May 15, 2018 Posted May 15, 2018 @Mark has indicated you can just hook on \IPS\Content\Search\Elastic\Index::indexData() and throw in whatever data you want. You don't need to predefine the fields in the index like we do.
Martin A. Posted May 19, 2018 Author Posted May 19, 2018 Should I do this for a MySQL search too (and create a new column in the table), or do a table join? I was just thinking that it might be a good idea to make it ready for 3rd party index data out of the box. What would happen if we all start making new indexes for our apps, with new random names? Wouldn't it be better if you have one or two extra columns reserved for this? And what it the point of you predefining the index fields if you don't need to? Will Elastic be slower if it has to filter on an undefined index? As mentioned in my OP, the whole search area is massive, and pretty much impossible to alter. Maybe it's time to look into making it extendable with extensions? I can imagine there are plenty of apps our there that would like to be able to filter their content by something more than views, posts and creation date.
bfarber Posted May 21, 2018 Posted May 21, 2018 Generally speaking it doesn't make sense for us to add stuff that isn't used by us. That's just bloat for 99% of clients.
Recommended Posts
Archived
This topic is now archived and is closed to further replies.