Movatterモバイル変換


[0]ホーム

URL:


BloomreachBloomreach
Hippo CMS

Bloomreach Documentation version

Bloomreach.com

Sanitize Search Input

HST'sSearchInputParsingUtils provide utility methods for sanitizing potentially malicious query strings by filtering out invalid characters or constraining the use of wildcards.

We recommend to always useSearchInputParsingUtils for free-text queries injected into anHstQuery.

For optimal performance, it is best to set theparse method's allowSingleNonLeadingWildCardPerTerm parameter tofalse:

final HstRequestContext context = request.getRequestContext();final HippoBean scope = context.getSiteContentBaseBean();HstQueryBuilder hstQueryBuilder = HstQueryBuilder.create(scope)        .ofTypes(BaseDocument.class);// PARSE the queryString query = getPublicRequestParameter(request, "query");String parsedQuery = SearchInputParsingUtils.parse(query, false);        if (StringUtils.isNotEmpty(parsedQuery)) {    hstQueryBuilder = hstQueryBuilder.where(constraint(".").contains(parsedQuery));}            final HstQuery hstQuery = hstQueryBuilder.build();final HstQueryResult result = hstQuery.execute();request.setAttribute("result", result);
Did you find this page helpful?
How could this documentation serve you better?
Cheers!
On this page
    Did you find this page helpful?
    How could this documentation serve you better?
    Cheers!

    [8]ページ先頭

    ©2009-2025 Movatter.jp