Skip to content

Search example

Stanislas Bernard 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: ''
}

Response :

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

Scoped search

Request :

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

Response :

{
    list: [ ...people... ],
    totalRecords: 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: {
        'FK_PEOPLE_COMPOSER': {
            list: [ ...composers... ]
            totalRecords: 46,
            label: 'composer'
        },
        'FK_PEOPLE_ACTOR': {
            list: [ ...actors... ]
            totalRecords: 355,
            label: 'composer'
        },
        'FK_PEOPLE_PRODUCER': {
            list: [ ...producers... ]
            totalRecords: 74,
            label: 'composer'
        },
    },
    totalRecords: 475,
    facets: {
        'FCT_PEOPLE_TITLE': {
            'f': 200,
            'm': 275
        },
        'FCT_PEOPLE_PROFESSION': {
            'composer': 46,
            'actor': 355,
            'producer': 74
        }
    }
}
Clone this wiki locally