We have some custom REST endpoints in our bap backend.
To implement some logic in the backend I’d like to:
Query documents of a certain model with a specific value in fieldA and return only the value of a fieldB (rather than the whole document or only its id).
It seems like the only “official” way to query is to use the DocumentQueryService. However, that returns only document ids and I would have to load each document separately and extract the field (which is very slow).
Is there a better way to do it?
spring-data-solr supports projections - see Spring Data for Apache Solr. If you don’t need to dynamically choose the model you probably can use that. If you dynamically want to choose the model you probably have to take a look how spring-data-solr implements this projection.
From an A12 perspective this seems like a task for Composed data (<INTERNAL_LINK>) which is not available in the version currently in use in the <PROJECT_NAME> project.
Unfortunately we do not support this use case because it goes against our goal of having custom loaders. We only want to provide a list of document references from the search service, for which we find loaders and load the documents. This means that the documents that are loaded could be different than the ones in the search index because of other extension points etc. We need to keep access to the documents (and their properties) unified for security and extensibility reasons