0
votes

I am working on integrating Elastic Search in my existing Django REST application. I am using the django-dsl-drf module provided in the link below:

https://django-elasticsearch-dsl-drf.readthedocs.io/

In their documentation 'exclude' query param is provided. But the query only when we provide the full field value.

search-url?exclude=<field-value

For eg: If I have a value 'Stackoverflow' in field 'name'. I'll have to provide query param a ?name__exclude=Stackoverflow to exclude records having 'Stackoverflow' as name in the result. I would like to implement a search in such a way that when I provide 'over', I need to exclude these records, similar to ?name__exclude=over

I checked the above tutorial, but I couldn't find it. Is there any work around so that I can exclude records, fields containing terms instead of providing full field value, which is also case-insensitive.

Thanks a lot.

1

1 Answers

0
votes

Using the contains functional filter, you can target documents that have their name field value containing the characters over anywhere in their terms:

?name__contains=over

However, as far as I know, there is no way to negate that filter in django-dsl-drf. You can create an issue requesting that feature, though, because odds are high that you're not the only who needs that, since it's a pretty common way of searching.