2020-02-05 19:05:49 -08:00
|
|
|
package utils;
|
|
|
|
|
|
|
|
import javax.annotation.Nonnull;
|
|
|
|
|
2023-12-06 11:02:42 +05:30
|
|
|
/** Utility functions for Search */
|
2020-02-05 19:05:49 -08:00
|
|
|
public class SearchUtil {
|
|
|
|
|
2023-12-06 11:02:42 +05:30
|
|
|
private SearchUtil() {
|
|
|
|
// utility class
|
|
|
|
}
|
2020-02-05 19:05:49 -08:00
|
|
|
|
2023-12-06 11:02:42 +05:30
|
|
|
/**
|
|
|
|
* Returns the string with the forward slash escaped More details on reserved characters in
|
|
|
|
* Elasticsearch can be found at,
|
|
|
|
* https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html#_reserved_characters
|
|
|
|
*
|
|
|
|
* @param input
|
|
|
|
* @return
|
|
|
|
*/
|
|
|
|
@Nonnull
|
|
|
|
public static String escapeForwardSlash(@Nonnull String input) {
|
|
|
|
if (input.contains("/")) {
|
2024-09-05 18:42:24 +02:00
|
|
|
input = input.replace("/", "\\/");
|
2020-02-05 19:05:49 -08:00
|
|
|
}
|
2023-12-06 11:02:42 +05:30
|
|
|
return input;
|
|
|
|
}
|
2020-02-05 19:05:49 -08:00
|
|
|
}
|