public class NlpSolverSearchHelper extends Object
Modifier and Type | Class and Description |
---|---|
static class |
NlpSolverSearchHelper.SearchType
Enumeration for the various search types.
|
Modifier and Type | Field and Description |
---|---|
static String |
RESERVED_TEXT_CHARACTERS
The reserved characters.
|
static Set |
s_ReservedWords
Oracle Text reserved words, will be escaped in 'simple' inxire iO
token strings.
|
Modifier and Type | Method and Description |
---|---|
static String |
getContainsClauseTerm(String searchTerm,
NlpSolverSearchHelper.SearchType type)
Return the text string to use in full text searches,
conforming to the database's syntax.
|
static String |
getContainsClauseTermOracle(String searchTerm,
NlpSolverSearchHelper.SearchType type)
Return the Oracle text string to use in the CONTAINS clause,
based on the specified term and the type of search requested.
|
static String |
getContainsClauseTermPostgres(String searchTerm,
NlpSolverSearchHelper.SearchType type)
Return the Postgres text string to use in to_tsquery() function,
based on the specified term and the type of search requested.
|
static String |
normalizeSearchPhrase(String searchPhrase)
Normalize a full text search phrase for entity phrases.
|
static String |
normalizeSearchTermOracle(String ctxString)
Normalize a search string for context search, i.e. replace double quotes
with curly parentheses '{}', escape all special characters as given
by
reservedCharacters with '\', and finally
replace '*' by '%' and '?' |
protected static String |
normalizeToken(String token)
Normalize given token.
|
protected static String[] |
tokenizeSearchTermOracle(String searchString)
Split context search string into tokens.
|
protected static String[] |
tokenizeSearchTermPostgres(String searchString)
Split search term into tokens.
|
public static final String RESERVED_TEXT_CHARACTERS
public static final Set s_ReservedWords
public static String normalizeSearchPhrase(String searchPhrase)
searchPhrase
- the search phrasepublic static String getContainsClauseTerm(String searchTerm, NlpSolverSearchHelper.SearchType type)
For Oracle, the term will be used in a CONTAINS clause. For Postgres, the term will be used in a to_tsquery() function.
searchTerm
- the BASIC search termsearchType
- the search typepublic static String getContainsClauseTermOracle(String searchTerm, NlpSolverSearchHelper.SearchType type)
searchTerm
- the BASIC search termsearchType
- the search typepublic static String getContainsClauseTermPostgres(String searchTerm, NlpSolverSearchHelper.SearchType type)
searchTerm
- the BASIC search termsearchType
- the search typeprotected static String[] tokenizeSearchTermOracle(String searchString)
Any token must contain at least one non-reserved characters (?), or it will be removed from list.
Tokens containing any Oracle Text reserved word, like AND
,
will be escaped.
Examples:
car garden
: car | garden
car* near(garden, flower)
: car* | near(garden, flower)
me and you
: me | "and" | you
:
searchString
- context search string containing list of tokensprotected static String[] tokenizeSearchTermPostgres(String searchString)
searchString
- context search string containing list of tokenspublic static String normalizeSearchTermOracle(String ctxString)
reservedCharacters
with '\', and finally
replace '*' by '%' and '?' by '_'.
If no search string is found, null is returned.
For complex searches all Oracle Text commands, like "and", "or" and "near" may be used or the special characters '"', '*', '?', . All other characters with special meaning for Oracle Text (InterMedia) are escaped.
Warning: the new version does not remove leading and trailing wildcards
automaticly. Call com.inxire.ioc.entity.AdvSearchParameter#ensureTwoCharacters(String)
to avoid
search strings with less than two characters.
ctxString
- search string, with '*' and '?' as wildcardsprotected static String normalizeToken(String token)
Any Oracle text reserved word will be escaped by double quotes.
token
- some token as used for inxire iO content searchNULL
)Copyright © 2023. All rights reserved.