Search Endpoint

Created by Iago Fernández · last update December 9, 2019

Implementation

Sorting
Send us a request with the fields you want to use for SORTING and we will configure it.
title A-Z: sort=name_sort asc

Boosting
Boosting allows you to modify the default ranking pushing to the top the documents matching the specified queries.
Boosting Nike and Rebook products:
boost=brand:Nike^2.1 OR brand:Rebook^1.3

Faceting
Send us a request with the list of fields that you want to use for FACETING and we will add it to the config.
facet={!ex=brand_facet}brand_facet

Here you can see an example of how to consume this service using Java.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
Client client;
WebTarget target;
public void init(){
    client = ClientBuilder.newClient();
    target = client.target("https://api.empathybroker.com/search/v1/query/{instance_id}/search")
       //Query parameters
        .queryParam("lang","ES")
        .queryParam("start",0)
        .queryParam("rows",5)
        .queryParam("sort","name_sort asc")
        .queryParam("sort","name_sort asc")
        .queryParam("boost","brand:Nike^2.1 OR brand:Rebook^1.3")
        .queryParam("facet","{!ex=brand_facet}brand_facet")
   
}
 
public JSON getResponse(String query){
    return target.queryParam("q",query).request(MediaType.APPLICATION_JSON).get(JSON.class)
}

Output

Example of multiple posible outputs from this endpoint

Results + TopTrends SpellCheck + TopTrends Suggestions + TopTrends

By default the service will return two json nodes, one for the search results (content) and another one for the topTrends.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
{
    content: {
        numFound: 14, /*Number of the documents return by the service*/
        docs: [ /*Json array with the documents returned by the service. Each one will contain all the fields configured to be returned by the search service.*/
                {
                    name: "Samsung Galaxy Note 10.1"
                },
                {
                    name: "Samsung SNH-1010N Smartcam"
                },
        ],
        facets: [/*filters, will contain one entry for each facet contained in the request using the facets param or directly configured in the search service by the EB Team.*/
                {
                    facet: "brand",
                    values: [
                        {
                            value: "samsung",
                            count: 13,
                            filter: "brand:samsung"
                        },
                        {
                            value: "SBS",
                            count: 1,
                            filter: "brand:SBS"
                        }
                    ]
                }
        ]
    },
    topTrends: [/*Popular trends, including category facet for the first one.*/
        {
            title: "<b>sams</b>ng",
            title_raw: "samsung",
            facets: [
                {
                    facet: "rootCategories_facet"
                    values: [
                        {
                             value: "Mobile Phones",
                             count: 5,
                             filter: "{!tag=rootFilter}rootCategories_facet:Mobile Phones"
                        },
                        {
                             value: "Phone Accessories",
                             count: 3,
                             filter: "{!tag=rootFilter}rootCategories_facet:Phone Accessories"
                        }
                    ]
                }
            ]
        },
        {
            title: "<b>sams</b>ung galaxy",
            title_raw: "samsung galaxy"
        },
        {
            title: "tablet <b>sams</b>ung",
            title_raw: "tablet samsung"
        }
    ]
}