Field-Specific Search - V2

General keyword-based search scans all the fields in Hawksearch marked as query-able. However sometimes in situations where we already know the field to be searched for, or would like to customize the search option to target a specific field alone, we can use the query filtering option to specify the field to be searched against.

Types of Search:

There are 4 different types of search that are supported. To apply these different types of the field needs to be suffixed with the type of search

  • keyword - exact match on an entire field value.

  • text - match on a single word within a field value.

  • prefix - match on the first characters of a single word in a field value.

  • wildcard match on a segment of a single word within a field value.

 

Field Setup for each type of search:

To make each type of search available, the field needs to be set up in a specific way within the Hawksearch admin.

  • keyword

    • Field Type

      • Field values are NOT stemmed

      • Field values indexed “as is“ AND are stemmed

  • text - match on a single word within a field value.

    • Field Type

      • Field values are ONLY stemmed (search only)

      • Field values indexed “as is“ AND are stemmed

  • prefix - match on the first characters of a single word in a field value.

    • Partial Query Type

      • Prefix

  • wildcard match on a segment of a single word within a field value.

    • Partial Query Type

      • Wildcard

 

Notes:

  • This can be used for fields which are not marked as query-able also.

  • Errors in this query field value are ignored, please double check your query if the result is not as expected.

  • This is equivalent to the Hawksearchable parameter used in Hawksearch versions 2.0L to 4.0L.

  • The format for fields that are set up as text in the Hawksearch admin is as follows “fieldname.{{typeofsearch}}” : ”value”.

  • The format for fields that are set up as numeric in the Hawksearch admin is as follows “fieldname” : ”value”.

  • Soft Errors will be thrown in the following scenarios and are not supported

    • Wildcard characters within the query value (must use a field specified as wildcard or prefix and not include * in the query value)

    • Phrase queries with proximity

    • Queries on fields that are not set up according to the guidelines above

    • Regular Expression Queries

    • Malformed queries

    • Queries that don’t specify a specific field

 

Examples:

The URL endpoints are available here - Hawksearch v4.0 - Search API

  1. Specifying the field name in the “query” parameter:

    POST /api/v2/search { "keyword" : "", "query" : "group_id.prefix: 12", "clientguid" : "SPECIFY YOUR CLIENT GUID HERE" }

     

  2. Use query parameter with the normal search:

    POST /api/v2/search { "keyword" : "perfect", "query" : "group_id.keyword: 123", "clientguid" : "SPECIFY YOUR CLIENT GUID HERE" }

     

  3. Use query parameter with the operators AND, OR, NOT:

    POST /api/v2/search { "keyword" : "perfect", "query" : "group_id.keyword: 123 OR group_id.keyword: 456", "clientguid" : "SPECIFY YOUR CLIENT GUID HERE" }

     

  4. Complex query parameter with multiple fields and the operators AND, OR, NOT:

     

  5. Query parameter with TO (range between two values)

     

  6. Query parameter with Math (numeric values)

     

  7. This feature is also available on Hawksearch’s Autocomplete API:
    Please note that the keyword is required for autocomplete request.

     

  8. Use query parameter with EXISTS operator to check for values:

     

  9. Use double backslashes \\ to escape the spaces:

     

  10. Use the backslashes with hawk_child_attributes and value also: