Search
The Search API is REST API that supports an HTTP Post operation. REST over JSON. The request and response payloads are JSON-based. The API presents filters and attributes in the request to enable full-text search using the product data models. This API supports full-text search across all fields present in the product modes that are marked for searching.
- Search Fields
The following fields of the Product data model are always considered for text searches.
- productID
<ns0:productId>PRODUCT_ID_1<ns0:productId>
- Product_Description
<ns0:description>PRODUCT_DESCRIPTION</ns0:description>
- Category
<ns1:characteristics> <ns1:name>CATEGORY</ns1:name>
- CompatibleSegment
The name and type of the segment.
<ns1:characteristics> <ns1:name>AS<ns1:name> <ns1:description>CompatibleSegment</ns1:description>
- Record_Type and
Record_Sub_Type
The name of the record type and the subtype.
<ns1:characteristics> <ns1:name>RECORD_TYPE</ns1:name> <ns1:value> <ns1:type>Feature</ns1:type> <ns1:discreteValue>PO</ns1:discreteValue> </ns1:value> <ns1:characteristics> <ns1:name>RECORD_SUB_TYPE</ns1:name> <ns1:value> <ns1:type>Feature</ns1:type> <ns1:discreteValue>ProductOffering</ns1:discreteValue> </ns1:value>
- Characteristics
Be default, characteristics are not searched so they have to be explicitly enabled for text searches.
<ns0:characteristics> <ns0:name>OPE_Char_A</ns0:name> <ns0:description>Characteristic</ns0:description> <ns0:simpleRule> <ns0:name>ISFULLSEARCHABLE</ns0:name> <ns0:ruleSetOutcome>true<ns0:ruleSetOutcome> </ns0:simpleRule>
- productID
- Keyword or phrases
You can search all products indexed into the Offer Search Engine for specific keywords or phrases.
When searching, a corresponding MatchQuery or MatchQueryPhrase is executed to look for occurrences of the specified text or phrase across all products and a score is attached to each. The response includes the products that contain the specified text or phrase that has the highest score. The score is based on the term frequency-inverse document frequency (TFIDF) which is a numerical statistic that reflects how relevant the text or keyword is to search. A higher score implies a higher relevancy and a closer match to the specified text or keyword.
Request Payload { "keyword": "OPE_Prod_A", //if its a phrase isPhrase”:”true” }
- Category
You can search for a specific category or multiple categories across all products indexed into the Offer Search Engine.
When searching for a specific category, the products that match the category are returned.
When searching for multiple categories, the union of matching products across all categories are returned.
Request Payload { "searchOfferQuery" : { "aggregate" : "false", "globalAggregate" : "false", "categories" : [ { "id": "test1", "name": "WEB" } ] } }
You can search for categories along with keywords or phrases. In such a search you would first find products based on a category (or categories) and then narrow the results using keywords or phrases.
The query in the following example searches for products that have 2GB and that fall in the WEB category:
Request Payload { “keyword”:”2GB” "searchOfferQuery" : { "aggregate" : "false", "globalAggregate" : "false", "categories" : [ { "id": "test1", "name": "WEB" } ] } }
The category search can be used to with attributes to filter out only those categories that have the particular attribute set. For example, the following request payload filters products based on keyword and category attributes across specific categories:{ "keyword":"PROD_A1", "aggAllCategories":"false", "aggAllSegments":"false", "searchOfferQuery" : { "aggregate" : "false", "globalAggregate" : "false", "attributes":"false", "categories" : [ { "id": "category_1", "name": "category_1" } ] }, "attributeFilters": { "attributes": { "IMP_DATE": [ "Samsung" ] } } } Response Payload { "totalHits": 1, "offers": { "offer": [ { "offerId": "PROD_A1", "offerDescription": "" } ] }, "suggestions": { "suggestion": null } }
- Segment
You can search for a specific segment name or type across all products indexed into the Offer Search Engine.
When searching for a specific segment name or type, the products that match the criteria are returned.
When searching for multiple segment names or types, the union of products that match the criteria are returned.
The query in the following request searches for products that match CHANNEL, WEB, and NOWEB.
Request Payload { "searchOfferQuery" : { "aggregate" : "false", "globalAggregate" : "false", "segments" : [ { "id": "test1", "type": "GROUP_CHANNEL", "name": "External Party" }, { "id": "test2", "type": "SUB_BRAND", "name": "LOOP" } ] } }
You can search for segments along with keywords or phrases. In such a search you would first find products based on a segments and then narrow the results using keywords or phrases.
The query in the following example searches for products that have 2GB in the model that also have the CHANNEL, WEB, and NOWEB classifications.
{ “keyword”:”2GB” "searchOfferQuery" : { "aggregate" : "false", "globalAggregate" : "false", "classes" : [ { "id": "test1", "type": "CHANNEL", "names": ["WEB","NOWEB"] } ] } }
Flag | Description |
isfullsearchable | Makes a particular characteristic searchable for full-text search. |
com.tibco.af.ope.flags.suggest=true | An application configuration that enables spelling suggestions to be included in response. |
aggallcategories | A request flag which returns aggregation of all categories linked to the product. |
aggallsegments | A request flag which returns aggregation of all segments linked to the product. |
aggofferclasses | A request flag which returns aggregation of all record types/sub types linked to the product. |
See sample search requests and responses at <OPE_HOME>/samples/request_response/search.