Comments (6)
I've updated the title, I can see that being a bit confusing. Sorting is what I meant originally but thought it was called Faceting. I see those are two separate things. You've understood correctly about the better sorting and replica support.
from algoliasearch-django.
Hi @thornycrackers, thanks for this feedback!
Improving the faceting handling in this project is definitely something we will consider, although I'm not sure what will be the timeline for implementing this feature.
This being said, your opinion is very valuable as it will help us shape the design of this feature! Can you share your thoughts about:
- What would you like to be able to do with a more integrated faceting?
- How would you like to use faceting in your django apps?
from algoliasearch-django.
So this is the code that I ended up using to make this happen myself. You guys will have a better idea on how to make a cleaner API for it than I.
from typing import Dict, List # noqa: F401
from algoliasearch_django import AlgoliaInde
class ReplicaExtendedIndex(AlgoliaIndex):
SORTING_REPLICAS = {} # type: Dict[str, List[str]]
# (https://www.algolia.com/doc/api-reference/api-parameters/customRanking/)
# E.G. 'model_name_ascending': {'ranking': ['asc(name)']},
def set_settings(self):
super().set_settings()
for index_name, settings in self.SORTING_REPLICAS.items():
index = self._AlgoliaIndex__client.init_index(index_name)
index.set_settings(settings)
def raw_search_sorted(self, model, sort_index: str, query='', params=None):
if params is None:
params = {}
if sort_index not in self.SORTING_REPLICAS.keys():
msg = 'sort {} by index {} is not implemented yet.'.format(model, sort_index)
raise ValueError(msg)
adapter = self._AlgoliaIndex__client.init_index(sort_index)
return adapter.search(query, params)
That way when I run algolia_applysettings
I will be able to have my replica indexes created. The search is added so that I can do raw searching with the ability to sort. I think these are pretty important, I would guess most people will incorporate some kind of sorting in there use of algolia. This way when I want to add a new index for a model I can use it like this
import ReplicaExtendedIndex
class MyModelIndex(ReplicaExtendedIndex):
SORTING_REPLICAS = {
'mymodel_name_ascending': {'ranking': ['asc(name)']},
'mymodel_name_descending': {'ranking': ['desc(name)']},
}
fields = ('name', 'description')
settings = {
'searchableAttributes': ['name', 'description'],
'replicas': list(SORTING_REPLICAS.keys())
}
Again this was pretty hasty but I think the easiest way of adding this feature is having some extra variable on the index class that allows you to define the additional indexes with their sorting and then have the methods incorporate them.
from algoliasearch-django.
Thanks for sharing this! So if I understand correctly, you're asking for better replicas support in Django, and especially supporting search with sort parameter by using the appropriate replica. This is a good idea, we'll definitely consider it for our next iterations on this project!
Just to make sure I don't get you wrong, this is unrelated to Faceting
, but rather about better handling Sorting
and replica indices?
If I'm right, then let's move your comment to a new issue about Sorting and replicas to make sure we address each topic separately! And in this case, do you still want to discuss Faceting for Models
?
If I'm wrong here, could you help me understand the link with Faceting?
from algoliasearch-django.
Thanks for the clarification! We'll update you here as we make progress on this feature ๐
from algoliasearch-django.
I've updated the title, I can see that being a bit confusing. Sorting is what I meant originally but thought it was called Faceting. I see those are two separate things. You've understood correctly about the better sorting and replica support.
@thornycrackers Hello,sir. How can i using your ReplicaExtendedIndex in Django View?
The 'raw_search_sorted' instead of 'raw_search' right?
from algoliasearch-django.
Related Issues (20)
- Django ORM query optimisations HOT 3
- Algolia reindex script tmp index move takes a long time. HOT 1
- Auto camel casing with Graphene HOT 1
- register decorator not working HOT 2
- disable indexing decorator not working HOT 2
- Relies on stale version of Algolia Python library HOT 4
- How to sorted replicas_index dynamic๏ผ HOT 3
- Containerize repository
- algoliasearch v1.20.0 still targeted as a dependency HOT 2
- Auto indexing when related model is changed HOT 3
- upon reindexing the main index overwrites its replica configurations - this behaviour should made configurable as it might be undesired
- which version start supporting django32 HOT 1
- Django algolia search: How to create search for multiple models HOT 4
- Unknown command: 'algolia_reindex' HOT 1
- How to put several models in one index HOT 1
- Preserve field names after preprocessing a field
- Support Multiple Algolia applications in one Django project
- Mapping Django and Algolia fields name
- Python 3.11 Support HOT 1
- Add support for Django 4.x series HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from algoliasearch-django.