I was recently using a search query to filter the last X documents matching a set of conditions. This is working as expected. A problem arose when I tried to sort documents by multiple fields before the conditions for FT.SEARCH are applied.
After searching a bit, I found that FT.SEARCH does not support multi-fields SORTBY but FT.AGGREGATE does. As a consequence, I tried to use FT.AGGREGATE similarly to FT.SEARCH but I noticed that by default FT.AGGREGATE does not return all fields for the matching documents. However, FT.SEARCH does return indexed and non-indexed fields by default.
Looking at the documentation it seems that I need to use LOAD with FT.AGGREGATE and to specify each field that needs to appear in the result. Since I have many fields and need to return them all, is there a specific syntax to say that all indexed and non-indexed fields must be returned similarly to FT.SEARCH, without enumerating all the fields?
My second question is about the warning when using LOAD with FT.AGGREGATE. My purpose is to make a search with a SORTBY on 3 different fields. These fields are SORTABLE. In that case, does using LOAD to return all fields has a higher cost than using FT.SEARCH?
The last question I have is how to retrieve the identifier of the documents that are matched. In my case, a query aggregation is used only for multi-fields SORTBY. Using a client library such as lettusearch the result type is a list of Document for FT.SEARCH, but a Map of String with FT.AGGREGATE. While a
Document contains a
getId method, I cannot find a field in the
Map to retrieve the identifier of the matching documents. Should I add the document ID as a dedicated field in the document when I add a document? or is there a solution to prevent duplicating this information?