Field-specific Search

πŸ“˜

Note

Please note: we recommend using this post as an initial reference for the newer article field-specific search for V2 field schema which also supports querying datetime and the Measurement Conversion feature.

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.

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 of this query parameter is β€œfieldname” : ”value”

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: 123",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Use query parameter with the normal search:
POST /api/v2/search  
{  
    "keyword" : "perfect",  
    "query" : "group_id: 123",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Use query parameter with the operators AND, OR, NOT:
POST /api/v2/search  
{  
    "keyword" : "perfect",  
    "query" : "group_id: 123 or 456",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Complex query parameter with multiple fields and the operators AND, OR, NOT:
POST /api/v2/search  
{  
    "keyword" : "",  
    "query" : "group_id:(123) AND (sku:ABC OR sku:DEF)",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Query parameter with TO (range between two values)
POST /api/v2/search  
{  
    "keyword" : "perfect",  
    "query" : "price[1.00 TO 10.00]",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Query parameter with Math (numeric values)
POST /api/v2/search  
{  
    "keyword": "perfect",  
    "query": "width: >7 AND width: \<=10",  
    "clientguid":"SPECIFY YOUR CLIENT GUID HERE"  
}
  1. This feature is also available on Hawksearch’s Autocomplete API:
    Please note that the keyword is required for autocomplete request.
POST request to /api/autocomplete  
{  
    "keyword" : "perfect",  
    "query" : "group_id: 123",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}
  1. Use query parameter with EXISTS operator to check for values:
POST request to /api/search  
{  
    "keyword" : "",  
    "query" : "_exists_: my_field",  
    "clientguid" : "SPECIFY YOUR CLIENT GUID HERE"  
}