You may need to modify the search logic dynamically using search logic editing
(sle
) in your search query.
Modifications made to the search logic (SearchLogic
class) are applied
after XML parsing and before Search API parameters.
Refer to the API Javadoc available in /<INSTALLDIR>/sdk/java-clients/docs/api/
for a full reference on the SearchLogic class.
Note:
If you modify the structure of the search logic, sle
queries are not
updated automatically and may not work properly. Use the Search API parameters to keep the
modifications you made to the search logic.
Build My Search Logic Editing
The structure of your search query is the following:
http://<HOSTNAME>:<BASEPORT+10>/search-api/search/search?q=mysearch&sle=<ACTION>:<FIELD>.<SEQUENCE>
[name="NAME"].<SEQUENCE>[0]
Where:
-
sle
indicates the use of search logic editing
-
<ACTION>
can either be:
-
add:
add an element in a list
-
set
: replace an element either in a field or in a list.
-
remove:
remove and element from a list.
Note:
Use the same data type. For example, you can only replace a character string
with another character string.
-
Use :
to separate action and fields
-
Use .
to separate fields or sequences
-
Use [0]
to select the first element in a list
-
Use [name="myname"]
to select the first element in a list with the
specified name
.
The full list of sequences is available in
Appendix - Search API Parameters in the Exalead CloudView Configuration
Guide.
Use Cases
-
To remove the highlight in titles displayed in the search results, use:
http://<HOSTNAME>:<BASEPORT+10>/search-api/search/search?q=mysearch&sle=remove:hitConfig.meta
[name="title"].metaSpecificOperation[0]
It:
-
To add a snippet, use:
http://<HOSTNAME>:<BASEPORT+10>/search-api/search/search?q=mysearch&sle=add:hitConfig.meta[name="title"]
.metaSpecificOperation=SnippetOperation(highlightFacetIds="Event,Person",highlightExtraPrefixHandlers=
"soundslike,spellslike",maxSentenceSegmentLength=210,maxLength=500)
It impacts the following section in
/<DATADIR>/config/SearchLogicList.xml
:
<s3:HitConfig fullHits="10">
<s3:Meta name="text">
<s3:FieldSource indexField="text"/>
<s3:SnippetOperation highlightExtraPrefixHandlers="soundslike,spellslike" highlightFacetIds="Event,
Person,Place_City,Place_Country,Place_State,Place_Landform,Place_CivicStructure,Place_MiscellaneousPlace,
Place_Misc,Organization_Corporation,Organization_GovernmentOrg,Organization_NGO,
Organization_MiscellaneousOrg,Organization_Misc" ifMetasMatch="" relaxAndNodesPolicy="toplevel"
highlight="true" splitOnSentences="true" maxConsecutiveSeparators="0" removeDuplicateSegments="false"
maxBytesToProcess="0" maxSentenceSegments="3" minNbWordsInRelevantSentence="10"
maxSentenceSegmentLength="2147483647" maxLength="500" minLength="1"/>
-
To add a prefix handler, use:
http://<HOSTNAME>:<BASEPORT+10>/search-api/search/search?q=mysearch&sle=add:uQLConfig.
queryPrefixHandler=FullTextPrefixHandler(name="title",indexFields="title",dictionaryName="dict0",
matchingMode="normalized")
The title
prefix handler is used in the search query.