django-haystack / django-haystack/django-haystack

Can django-haystack filter MultiValueFields like in given example?

Open
#1,564 0 comments 2 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
3.7k
Forks
1.3k
Avg merge
3h 18m
Merged PRs (30d)
3

Description

Can django-haystack filter MultiValueFields like in following example?:

persons = indexes.MultiValueField()

Example data:
persons = [{"name": "John", "occupation": "artist"}, {"name": "Paul", "occupation": "teacher"}]

import haystack
haystack.query.SearchQuerySet().filter(persons__occupation="teacher")

I guess no? So instead I should create a field for each occupation like so?:

teachers = indexes.MultiValueField()

Example data:
teachers = ["Paul", "Henry"]

So that I basically avoid filtering. Now I could just do, which gets all indexes where teachers is not empty:
haystack.query.SearchQuerySet().filter(teachers=Raw("*"))

Or do you recommend to use a Raw elasticsearch query with my first example too?

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with MultiValueField and SearchQuerySet.filter, then inspect how the Elasticsearch Raw query path is exposed. Determine whether nested occupation filtering is supported; done means documenting the supported query or a clear limitation and recommended field representation.

Written by the indexing model from the issue text.

Assessment

Tech stack
elasticsearch, python
Domain
search
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.