0
votes

I want to implement multi-facet interaction by MarkLogic search:search API. In MarkLogic jsearch.facets there is one option 'othersWhere' which may help to build the same. However, I want to implement it by search:search.

Could I achieve this by creating custom facets with search:search API?

For example, I have one element <color> which has values green, red, blue and white. In normal scenario, whenever user will click on color:green it will hide the other options, but I want to select multiple values from the same constraint.

2

2 Answers

0
votes

You can absolutely specify more than one value for a constraint to apply with search:search. For example a search string like:

color:"Red" OR color:"Green"

..Will return all documents with a color of red or a color of green using the "color" constraint.

To me this sounds mostly like a UI building challenge.

0
votes

That will be difficult I'm afraid. You can take search:search apart, and do search:parse and search:resolve separately, giving you somewhat more flexibility, but that still doesn't really help with doing what you are trying to do. For this, you'd need to resolve each facet separately, and pass in a tweaked query each time, essentially omitting the query part for the facet itself each time. That is rather cumbersome, and MarkLogic would be unable to optimize subsequent facet calculations.

As an alternative, why don't you hold on to the facet while a user is still clicking, and only submit when the user has selected all values for the facet? I've done this in the past. The user would toggle to a multi-select mode for a facet, and in that case, the user could checkbox as many values as desired, and would finish off with a button-click to apply.

HTH!