notanumber / xapian-haystack

A Xapian backend for Haystack
GNU General Public License v2.0
154 stars 93 forks source link

Add DJANGO_CT, DJANGO_ID, ID to be used with '__exact' internally. #232

Closed karolyi closed 1 year ago

karolyi commented 1 year ago

Hey,

somewhere around 8568e49b8f350ea3ce1358fad014c40b84f087b6 an exclusion has been added to django_ct with an __exact search. I need to add the other django internal fields excluded from text searches as well.

In my use case I .exclude( some IDs for which I search for with the internal id field, that is a text field and did get escaped as a phrase because of that. My code uses SearchQuerySet.exclude(id__list=['id_1', 'id_2'] which in the current state will not work.

These commits are about that, and also about preparing a new release. Please do a release ASAP, as I need these changes and can't use the official packages until this gets merged. I'm using my on gitea mirror for now, but would like to get back to using the official packages.

coveralls commented 1 year ago

Coverage Status

Coverage: 97.565% (+0.007%) from 97.558% when pulling 0dcc9581970b915cab827f7db839d708c6814742 on karolyi:master into 251e9241225b643acefe125d5d7444f8ff19f77e on notanumber:master.

karolyi commented 1 year ago

@claudep hey, can we pick up some pace here please?

karolyi commented 1 year ago

I can remove the release, but I have no idea what you mean when you talk about the regression tests.

What I know though is, before the mentioned change in the commit, I could excloude ids, and now I can't.

karolyi commented 1 year ago

I created a test for myself though (in my private system) that tests for this, maybe this can help:

from django.test.testcases import TestCase
from haystack.query import SearchQuerySet

class HaystackXapianBackendTestCase(TestCase):
    'Testing haystack with xapian backend.'

    def test_exclude_by_id(self):
        'Test if the ID field is not phrased.'
        # See https://github.com/notanumber/xapian-haystack/pull/232
        sqs = SearchQuerySet().exclude(id__in=['testing123', 'testing456'])
        expected = \
            'Query((<alldocuments> AND_NOT (Qtesting123 OR Qtesting456)))'
        self.assertEqual(first=str(sqs.query.build_query()), second=expected)
claudep commented 1 year ago

Yes, this is a good start. Now you will have to include that test somewhere in https://github.com/notanumber/xapian-haystack/tree/master/tests/xapian_tests/tests.

karolyi commented 1 year ago

Alright, I can do that, if you can promise a timely release.

claudep commented 1 year ago

Depends on what you call "timely", do not forget we are volunteers!

karolyi commented 1 year ago

do not forget we are volunteers!

yeah, so am I. good news: I've added the test, reverted the version bump, and squashed the commits into one single, clean commit. tests are running, we should be good to go!

karolyi commented 1 year ago

Nice, now all I need is a release.

Is that in your power to do?

claudep commented 1 year ago

See PR #233