Sunday, August 21, 2022
HomeWordPress DevelopmentAuto Index and Search Django Mannequin Cases with RediSearch (utilizing redis-search-django)

Auto Index and Search Django Mannequin Cases with RediSearch (utilizing redis-search-django)




Overview of My Submission

I constructed an Installable Django Bundle referred to as redis-search-django as part of Redis Hackathon on DEV. redis-search-django is a Django bundle that gives auto indexing and looking out capabilities for Django Mannequin situations utilizing RediSearch.

redis-search-django internally makes use of redis-om-python and redis-py

redis-search-django is Out there on Python Bundle Index (PyPI): https://pypi.org/challenge/redis-search-django/

You may set up it by working: pip set up redis-search-django



Options

  • Administration Command to create, replace and populate the RediSearch Index.
  • Auto Index on Mannequin object Create, Replace and Delete.
  • Auto Index on Associated Mannequin object Add, Replace, Take away and Delete.
  • Simple to create Doc courses (Makes use of Django Mannequin Kind Class like construction).
  • Index nested fashions (e.g: OneToOneField, ForeignKey and ManyToManyField).
  • Search paperwork utilizing redis-om.
  • Search End result Pagination.
  • Search End result Sorting.
  • RediSearch End result to Django QuerySet.
  • Faceted Search.



Submission Class:

Wacky Wildcards
(As a result of a Django Bundle doesn’t match into different Classes)



Language Used



Hyperlink to Code

Django Bundle Repository:

Django bundle that gives auto indexing and looking out capabilities for Django mannequin situations utilizing RediSearch.

Pypi Version
Supported Python Versions
Supported Django Versions
License

Django Tests
Codecov
pre-commit.ci
Changelog-CI
Code Style

A Django bundle that gives auto indexing and looking out capabilities for Django mannequin situations utilizing RediSearch.

  • Administration Command to create, replace and populate the RediSearch Index.
  • Auto Index on Mannequin object Create, Replace and Delete.
  • Auto Index on Associated Mannequin object Add, Replace, Take away and Delete.
  • Simple to create Doc courses (Makes use of Django Mannequin Kind Class like construction).
  • Index nested fashions (e.g: OneToOneField, ForeignKey and ManyToManyField).
  • Search paperwork utilizing redis-om.
  • Search End result Pagination.
  • Search End result Sorting.
  • RediSearch End result to Django QuerySet.
  • Faceted Search.
  • Python: 3.7, 3.8, 3.9, 3.10
  • Django: 3.2, 4.0, 4.1
  • redis-om: >= 0.0.27

Downloading Redis

The newest model of Redis is offered from Redis.io. You may as well set up Redis along with your working system’s bundle supervisor.

RediSearch and RedisJSON

redis-search-django depends on the RediSearch and RedisJSON Redis modules to help wealthy queries and embedded fashions
You want these Redis…

Demo App Repository:
(README file accommodates the small print as per Hackathon Necessities)

I constructed an Installable Django Bundle referred to as redis-search-django as part of Redis Hackathon on DEV
redis-search-django is a bundle that gives auto indexing and looking out capabilities for Django mannequin situations utilizing RediSearch.

This can be a Demo App that makes use of redis-search-django bundle to Showcase a Product Search Engine with auto indexing and looking out.

redis-search-django Documentation: https://github.com/saadmk11/redis-search-django

Options

  • Administration Command to create, replace and populate the RediSearch Index.
  • Auto Index on Mannequin object Create, Replace and Delete.
  • Auto Index on Associated Mannequin object Add, Replace, Take away and Delete.
  • Simple to create Doc courses (Makes use of Django Mannequin Kind Class like construction).
  • Index nested fashions (e.g: OneToOneField, ForeignKey and ManyToManyField).
  • Search paperwork utilizing redis-om.
  • Search End result Pagination.
  • Search End result Sorting.
  • RediSearch End result to Django QuerySet.
  • Faceted Search.

App Screenshot

RediSearch Django

The way it works

Create Search

…



Further Assets / Information



use it

Create Search Doc from Django Mannequin. (Utilizing redis-search-django)

1. For Django Mannequin:

# fashions.py

from django.db import fashions


class Class(fashions.Mannequin):
    title = fashions.CharField(max_length=32)
    slug = fashions.SlugField(max_length=64)

    def __str__(self) -> str:
        return self.title
Enter fullscreen mode

Exit fullscreen mode

2. You may create a doc class like this:

# paperwork.py

from redis_search_django.paperwork import JsonDocument

from .fashions import Class


class CategoryDocument(JsonDocument):
    class Django:
        mannequin = Class
        fields = ["name", "slug"]
Enter fullscreen mode

Exit fullscreen mode

3. Run Django Administration Command Index to create the index on Redis (Solely have to run as soon as to generate Index Schema on Redis):

python handle.py index
Enter fullscreen mode

Exit fullscreen mode

Word: This will even populate the index with current information from the database

Now class objects might be listed mechanically utilizing Redis on create/replace/delete occasions.

Extra Complicated Examples May be discovered right here: https://github.com/saadmk11/redis-search-django



Screenshot of the Demo App:

Image description


RELATED ARTICLES

LEAVE A REPLY

Please enter your comment!
Please enter your name here

- Advertisment -
Google search engine

Most Popular

Recent Comments