Conversation
…Index for comparison
olovy
reviewed
Feb 24, 2026
…truction to Elasticsearch class
olovy
approved these changes
Mar 5, 2026
Contributor
olovy
left a comment
There was a problem hiding this comment.
Nice. Great work!
As discussed in online review, I think this is good to go.
🚢
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Add extended support for Fresnel features and refactor how search cards/chips are built for indexing.
Key changes:
fresnel:subLensandfresnel:mergeProperties(https://www.w3.org/2005/04/fresnel-info/manual/)FresnelUtilinstead of JsonLd.toCardThe main goal is to reduce the number of indexed fields while improving control over how search cards are constructed.
fresnel:mergePropertiesfor merging values from multiple properties into a single indexed field instead of creating separate fields.startYearandyearinto a common fieldlibrissearch:year. (In this case we actually create an extra field!)fresnel:fslselector(already supported) to include values more than one step away from the main entity. For example for selecting specific record properties for indexing instead of including the entireRecordchip for every single linked thing from embellish._strfields only for entitities with defined search tokens. The_strcontent is dervied from those definitions.fresnel:subLenswe don't have to define individual search tokens for nested entities (e.g.TitlePart) and thereby prevent unwanted_strfor those entitites.So far I've focused on the immediate use cases, but I think they serve as examples of how we can use these mechanisms to further decrease the number of index fields. Surely we can find more optimizations if we analyze the current search card definitions.
On local test data, this results in ~25% fewer indexed fields, likely because we no longer include the full Record chips everywhere. Nothing appears to break when removing those fields, but this needs validation.
Indexing procedure
One problem with the previous indexing procedure (i.e. ElasticSearch.getShapeForIndex) was data being filtered during the initial
embellishand thus data needed for search-card lenses was already lost. Instead perform a "full" embellish and then shrink them once according to the lens definitions.search-cardto:search-chipto non-integral embellished entities.FresnelUtil changes
This class has been heavily refactored to accommodate new features and more flexibility. Mechanisms already in use should behave the same however.
Some behavior needed to be more robust or pushed up to the surface for clarity. For example clarifying how lenses are applied at different levels in the document structure. As an example
CHIP_TO_TOKENmeans:chiptoken, thenchipThis stuff can surely be made even more clear and maybe fits better as configuration than hard-coded.
I don't think there is a point in looking at the diff (it's huge) for
FresnelUtilwhen reviewing, rather look at the public methods, and their usage (including unit tests).TODO / Open questions
FresnelUtilcan be used for creatingsortKeyByLangfrom chip definitions (here). This was previously done with JsonLd.applyLensByLang and some of its behavior may need to be replicated:FIXED: 6421c2a / 4f53d23
search2for searching language tagged fields. The individual lang fields (e.g. xByLang.sv) are not needed for search, however we do rely upon them for display so we can't remove them from the indexed docs.Can we remove them from mappings instead? Something to look into.UPDATE: d99e452 removes byLang fields from ES mappings. Reduces the number of mapped fields with another ~10% on local test data.
UPDATE: Done: libris/definitions@4c002d7
UPDATE: Use the default lens as fallback.
FresnelUtilclass is still huge and should be decomposed./librissearch:yearPublishedpublication.librissearch:yearfor sorting/facetingon bothyearandstartYear.There is probably more to be said but let's start the discussion from here.
See also libris/definitions#548