After various tests by our team, Elasticsearch 7.2 is now available on Bonsai. This is a fairly major release, and has quite a few benefits as well as changes to note. We’re highlighting the ones that will likely impact our customers the most.Bonsai <3 Rank FeatureElasticsearch is now exposing the Lucene FeatureField type. This field type will let you store a precomputed value in the field, rather than having to compute the value during query time. Offloading this work to the indexing process will help keep your customers happy with snappy search response times.In Elasticsearch, you can leverage this new feature by mapping your properties to the type rank_feature. Read up on the specific Elasticsearch mapping syntax. Once you’ve indexed your documents, you can they start to use the Elasticsearch query syntax to search them using these new features.
Script Scoring, Oh, My!
Here is another hot off the presses feature that we are excited about. Script Score Query is Elasticsearch’s replacement of the “Function Score” which will soon be deprecated. Both of these features will allow you to tweak the scoring of matching documents after they have been retrieved, which reduces the amount of computation needed to score the various documents.With Script Score Queries, you are no longer limited to a pre-defined set of functions but can leverage the scripting capabilities of Elasticsearch to their full extent, giving you more power to implement just the right relevance needed for you and your customers.One trick that I really like is using the time based decay functions to temporarily boost new documents that might not get picked up by other boosting measures, such as a boosting based on popularity.
Improved Search Response Time for Large Corpuses
When you have a large number of documents in your index, and any given query might return thousands of documents, your customers may not be concerned with the exact number of documents that match the query. If there are over 10,000 documents that match my query, is your user really planning to page through all of those results, or are they only going to look at the first page or two?With Elasticsearch 7, we can now specify the track_total_hits parameter in a query. This will help reduce the amount of time a query takes, since it will no longer have to count the full result set of low value scoring documents. For any result set less than the value set in track_total_hits, Elasticsearch will return the correct number. For values over that amount, the query will tell you that it was greater than the number. Then you can draw your UI correctly for the user.Faster top k queries is a key new feature for improving search results. Elasticsearch 7.0 implements a new algorithm that provides a huge speed boost when retrieving top hits for any given search query.