SRP API - "Contains" Search or Full Text UGC Filtering?
Is it possible to filter strings by "contains" or maybe a full text search for UGC?
I've tried a ValueConstraint<String>[1] but looks like I can only perform a "begins with" search based on the available ComparisonTypes[2]. Even still, this doesn't seem to work...
final UgcFilter filter = new UgcFilter(); // ... final String titleFilterParam = request.getParameter("title"); ConstraintGroup optionalFilters = new ConstraintGroup(Operator.Or); Constraint titleFilter = new ValueConstraint<String>("postTitle", titleFilterParam, ComparisonType.BeginsWith); optionalFilters.addConstraint(titleFilter); filter.and(optionalFilters);So then I tried a FullTextConstraint[3] on a specific property and that doesn't seem to work either.
final UgcFilter filter = new UgcFilter(); // ... final String titleFilterParam = request.getParameter("title"); ConstraintGroup optionalFilters = new ConstraintGroup(Operator.Or); optionalFilters.addConstraint(new FullTextConstraint(titleFilterParam, "postTitle"); // not sure which wildcard is valid (if any), no documentation on this optionalFilters.addConstraint(new FullTextConstraint("*" + titleFilterParam + "*", "postTitle"); optionalFilters.addConstraint(new FullTextConstraint("%" + titleFilterParam + "%", "postTitle"); filter.and(optionalFilters);I've looked at the only filtering examples I've seen from Adobe on the github here[4] but that only shows an example of a ValueConstraint<Boolean> and a PathConstraint[5]. String value comparison using ValueConstraint<String> also seems to have a hard time with capitalization and spaces, so I've had to lowercase and replace all spaces with hyphens for string comparison, for now. Is there a better way to do this?!
I guess I could always just filter in my code after the fact, but figured we should get the UgcFilter correct the first time. This is extremely frustrating though, considering I can't get a printout of what the final UgcFilter looks like before querying Solr (like what the final XPath/JCR-SQL2/etc query string is).
[1] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/social/ugc/api/ValueConstraint.html
[2] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/social/ugc/api/ComparisonType.html
[3] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/social/ugc/api/FullTextConstraint.html
[4] https://github.com/Adobe-Marketing-Cloud/aem-communities-todomvc-sample/blob/master/bundles/aem-communities-todomvc/src/main/java/com/adobe/aem/social/todomvc/impl/TodoListImpl.java#L79
[5] https://docs.adobe.com/docs/en/aem/6-2/develop/ref/javadoc/com/adobe/cq/social/ugc/api/PathConstraint.html