Jump to content

Add custom data to Elastic index


Martin A.

Recommended Posts

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.

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...