AI OnAI Off
Hi Sebastian,
If you could convert, expose and index string MultiCvlValues as an additional field of type IEnumerable<string> then you should be able to do
.Filter(x => x.MultiCvlValuesAsIEnumerable.Match("Grease"));
If you need more hands-on support around this I suggest you create a support case with support@optimizely.com
.Filter(x => x.MultiCvlValuesAsIEnumerable.In(new List
Hey!
We have a client that uses alot of legacy find implementations for building and matching indexed fields using query.Filter and the FilterBuilder. This has worked fine but now they want to introduce a new type of filter called "MultiCvlFilter" that we're abit unsure about how to match using .Filter and the FilterBuilder. So I will try to give as much detailed information as possible and show the process steps the filtering takes, maybe somebody has some input that might help us in the right direction.
MultiCvl is basically a field with multiple values that should all individually be matched against a single selected filter.
----------------------------------------------
Frontend
This is an example of what a multicvl filter might look like in the frontend, both ItemMedias and ItemCompatibleWith are multicvl-filters that might appear in one or multiple articles.
----------------------------------------------
Index
Below is what the indexed field looks like in the index, this is a collection of all multicvlfilters that this product or article has, so it's not split up by what the field is named but indexed in a combined field (instead of one field for ItemMedia, one field for ItemCompatibleWith etc.")
The idea is that if you select a filter that is a multicvlfilter, it should be matched against each individual value in this field. So let's say the selectedFilter ultimately ends up being "Air from ItemMedias" , it should not match the above row, but if I select "Grease" it should.
----------------------------------------------
Step by step
Step 1:
This is the SearchService method that handles the search initially (after the controller passes it here). I've excluded some of the more basic filterings and included what I think is important to see:
----------------------------------------------
Step 2:
This is the FilterSelected method where - in short - the query is extended and funneled down based on what selectedFilters are present. In our case, we have a flag on the filter itself that allows us to determine if the filter is of the new sort (MultiCvl) or not, and pipe it further accordingly.
----------------------------------------------
Step 3:
This is the FacetStringDefinition which holds the method MultiCvlFilter<T> from above, and for now all that method does is make it possible to handle this type of filter differently, but right now it just pipes it fordward to the next step just like the normal filters (the Filter<T> method below)
----------------------------------------------
Step 4:
This is the SearchExtensions where we ultimately end up with any type of filter (before this "new" filter, all we had was the regular stringfilter, and the intervalfilter).
So that's basically the entire route the search and filtering takes, I've tried to add // !! comments to the code snippets to guide you. There are other methods as well, but we think that this is where the source of the problem and also the solution for it lies. We are of course open to suggestions and input if you have any, and the ultimate goal is to get the filtering to work in symbiosis with the structure that is already in place, while the long term goal is to rethink the whole approach to filtering.
In the above scenario, let's pretend we've selected "Grease" from the ItemMedias filter, so:
stringFieldValues contains one string value, which is "Grease".
fieldName is MultiCvlValues$$string, we're not storing these as "ItemMedias" or "ItemCompatibleWith" but as one combined field.
So the problem is, I have no idea how I should set up the FilterBuilder to match Grease to this field in the index which contains Grease, as part of the commaseparated string.