Skip to content

Search example

NPi2Loup edited this page Jun 16, 2015 · 17 revisions

Example of a search action between the client and the API

Unscoped search

Request :

{
    criteria: {
        query: 'test',
        scope: 'ALL'
    },
    facets: [],
    group: 'FCT_SCOPE'
}

Response :

{
    groups: {
        'Movies': [ ...movies... ],
        'People': [ ...people... ]
    },
    facets: {
        FCT_SCOPE : {
            'Movies' : 475,
            'People': 136
        }
    },
    totalRecords: 611 // 475+136
}

Scoped search

Request :

{
    criteria: {
        query: 'test',
        scope: 'PEOPLE'
    },
    facets: [],
    group: ''
}

Response :

{
    list: [ ...people... ],
    total-count: 475,
    facets: {
        'FCT_PEOPLE_TITLE': {
            'f': 200,
            'm': 275
        },
        'FCT_PEOPLE_PROFESSION': {
            'composer': 46,
            'actor': 355,
            'producer': 74
        }
    }
}

Scoped search with grouping

Request :

{
    criteria: {
        query: 'test',
        scope: 'PEOPLE'
    },
    facets: [],
    group: 'FCT_PEOPLE_PROFESSION'
}

Response :

{
    groups: {
        'composer': [ ...composers... ],
        'actor': [ ...actors... ],
        'producer': [ ...producers... ]
    },
    total-count: 475,
    facets: {
        'FCT_PEOPLE_TITLE': {
            'f': 200,
            'm': 275
        },
        'FCT_PEOPLE_PROFESSION': {
            'composer': 46,
            'actor': 355,
            'producer': 74
        }
    }
}
Clone this wiki locally