inveniosoftware / invenio-records-rest

Invenio records REST API module.
https://invenio-records-rest.readthedocs.io
MIT License
4 stars 63 forks source link

views: suggesters support source filtering for ES5 #226

Closed iulianav closed 6 years ago

iulianav commented 6 years ago

Make ES5 suggesters support source filtering in order to save network overhead by filtering out useless fields from the _source key (or just strip _source altogether) returned in the response. Suggester fields configuration should now contain a _source key that will specify the source filtering for each suggestion field. The possible values for the _source key are the same as the ones specified in source filtering documentation.

Example configuration:

'suggesters': {
        'author': {
            '_source': ['name', 'age'],
            'completion': {
                'field': 'author_suggest',
            },
        }
}

With the current test structure, it is not possible to add a reliable test to handle both ES2 and ES5.

Signed-off-by: Iuliana Voinea iulianavoinea96@gmail.com

iulianav commented 6 years ago

@lnielsen as I mentioned, with the current test structure, it am not sure it is possible to add a reliable test to handle both ES2 and ES5. What do you think?

lnielsen commented 6 years ago

Sorry, didn't see the last comment. In the test I think you can do the same as the in the code

if ES_VERSION[0] >= 5:
    # assert that a non-requested field *is not* returned
else: 
    # assert that a non-requested field *is* returned

This way Travis will run both on v2 and v5 and the test coverage should make sure we have both lines covered.

iulianav commented 6 years ago

@lnielsen I was considering it at some point, but then it seemed like a bad practice... however, if you are ok with it I shall do it this way! Thanks!

drjova commented 6 years ago

ping @lnielsen