django-haystack / django-haystack/django-haystack

Bads results from queryset

Open
#1,403 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend : xapian needs review query
Dominant language
Python
Stars
3.7k
Forks
1.3k
Avg merge
3h 18m
Merged PRs (30d)
3

Description

Key is unique.

First case:

Foo.objects.filter(key="ABCD") 
>> [<Foo: Foo object>] 
Foo.objects.filter(key="A") 
>>[] 

Second case (Xapian) , after doing rebuild_index:

sqs = SearchQuerySet()
search = sqs.models(CertificationApplicant)

search.filter(key="ABCD")
>> [<SearchResult: foo.foo (pk=62)>] #only one it's ok

search.filter(key__exact="ABCD")
>> [<SearchResult: foo.foo (pk=62)>] #only one it's ok

search.filter(key=Exact("ABCD"))
>> []   #WHY no result ???

search.filter(key="A")
>> [<SearchResult: foo.foo (pk=62)>, [<SearchResult: foo.foo (pk=124)>, u'...(remaining elements truncated)...'] 

search.filter(key__exact="A")
>> [<SearchResult: foo.foo (pk=62)>,  [<SearchResult: foo.foo (pk=124)>, u'...(remaining elements truncated)...']  #WHY multiple results ????

search.filter(key_exact=Exact("A"))
>> [] # WHY ?

I would like same behavior of "Foo.objects.filter(key="ABCD") " but with Xapian.

Configuration

  • Operating system version: MacOsx 10.11.5
  • Search engine version: xapian-haystack==2.0.0
  • Python version: 2.7.1
  • Django version: 1.4.2
  • Haystack version:

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 by reproducing the Foo.objects.filter and SearchQuerySet.filter examples with xapian-haystack 2.0.0, Django 1.4.2, and Python 2.7.1. Trace how key, key__exact, and Exact("...") are translated for the Xapian backend. Done means exact filtering matches Django queryset behavior without returning partial or multiple results.

Written by the indexing model from the issue text.

Assessment

Tech stack
django, python
Domain
search
Issue type
Bug
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.