社区所有版块导航
Python
python开源   Django   Python   DjangoApp   pycharm  
DATA
docker   Elasticsearch  
aigc
aigc   chatgpt  
WEB开发
linux   MongoDB   Redis   DATABASE   NGINX   其他Web框架   web工具   zookeeper   tornado   NoSql   Bootstrap   js   peewee   Git   bottle   IE   MQ   Jquery  
机器学习
机器学习算法  
Python88.com
反馈   公告   社区推广  
产品
短视频  
印度
印度  
Py学习  »  Django

Django algolia搜索:如何创建多个模型的搜索

Santhosh • 4 年前 • 424 次点击  

在Django,我有4种不同的型号

class Baby(model.Model):
    name = ... #(babys name)
    description = ...
    .... other fields not common

class BabyStore(model.Model):
    name = ...  #(name of the shop)
    description = ...
    .... other fields not common

class BabySitter(model.Model):
    name = ... #(babysitter name)
    description = ....
    .... other fields not common

class BabyDoctor(model.Model):
    name = ... #(babydoctors name)
    description = ...
    .... other fields not common

根据 https://github.com/algolia/algoliasearch-django 我们必须登记每种型号

import algoliasearch_django as algoliasearch

from .models import YourModel

algoliasearch.register(YourModel)

这将为每个模型创建单独的索引。

在我的例子中,我希望有一个搜索UI,将所有这些都放在一起,并使用模型作为方面。

如:

enter image description here

那么,如何使用多个索引并创建单个搜索呢

我知道在每个索引中,我们都可以有方面。但在这里,我想把每个索引本身作为一个方面来使用

Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/131920