I am using Azure Search and Spring. Using @RequestParam, I get my filter parameters from someurl?varEquals=X&otherIn=A&otherIn=B
into a MultiValueMap<String, List<?>>. I also do not know what these filter fields (var, other) will be beforehand.
How do I make this MultiValueMap useable as a filter that connects to an Azure Search resource?
Approach 1:
I have tried one approach which is using azure.search.documents.SearchOptions, which takes in an OData $filter query as a string. The string should look like:
var eq 'X' and search.in(other, 'A, B')
which works when plugged into SearchOptions’ .setFilter() function.
Approach 2:
I’ve only just started this approach. This is using org.springframework.ai.vectorstore, which should give me something like:
new Expression(AND, new Expression(EQ, new Key("var"), new Value("X")),
new Expression(IN, new Key("other"), new Value(List.of("A", "B")));
The Problem:
I’ve written a parser to spit out a string in the correct format for the first approach and it works. The problem is, I don’t think writing the parser myself is the most efficient way to go from MultiValueMap to either OData $filter or VectorStore filter code. Is there a way to more easily convert from MultiValueMap to one of the expressions above than writing out a whole parser?