Using the HTTP Search Command

If you do not want or cannot use the Java or .NET clients, you can directly access the search command.

This page discusses:

About HTTP Search Queries

You send search queries to the command by:

  • Sending a GET request to http://host:port/COMMAND_BASE/search

  • Sending an application/x-www-form-urlencoded POST request to http://host:port/COMMAND_BASE/search

Search queries are key-value sets of search arguments. The full list of arguments is available in the Search API Parameters Reference documentation.

The main arguments are:

  • "q": the query

  • "l": the ISO code of the language

For example, the following query http://host:port/search-api/search?q=test&l=en

The reply of the Search command is an XML object representing the answer. The two main parts of the answer object are:

  • The results of the query, in the top level <hits> node. Each hit consists of facets:

    • In the <groups> node of this hit,

    • And meta values in the <metas> node.

  • The facets of the query, in the top level <groups> node.

Change Search Logic Dynamically

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:

    • Finds the first meta with name equal to title

    • Removes the first element in metaSpecificOperation list

  • 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.