Django

Code

Ticket #2559 (closed: fixed)

Opened 2 years ago

Last modified 1 year ago

[patch] Operators for search_fields

Reported by: Andy Dustman <farcepest@gmail.com> Assigned to: adrian
Milestone: Component: django.contrib.admin
Version: SVN Keywords:
Cc: farcepest@gmail.com Triage Stage: Unreviewed
Has patch: 1 Needs documentation: 0
Needs tests: 0 Patch needs improvement: 0

Description

Currently, search_fields in Admin always do an icontains search, i.e. ILIKE %...% search where ... is the search term. This is inefficient and undesirable in many cases because you cannot use an index and the database must search all rows.

The following patch (to be attached) extends this to add the following prefix operators and corresponding searches:

  • ^: istartswith
  • =: iexact
  • @: search (full-text)
  • no prefix: icontains (current behavior)

My tests indicate ^ makes my searches a lot faster. However, if there is at least one search field without a prefix, the database will still have to check every row.

Attachments

django-search_fields-operators.diff (1.3 kB) - added by Andy Dustman <farcepest@gmail.com> on 08/17/06 17:41:33.
Implementation
django-search_fields-operators-docs.diff (1.3 kB) - added by Andy Dustman <farcepest@gmail.com> on 08/17/06 18:08:50.
Documentation
django-search_fields-operators_pre_magic_removal.diff (1.4 kB) - added by eric@ericwalstad.com on 08/17/06 20:09:53.
The same patch back-ported to the pre-magic-removal tag (changeset r2808)
django-search_fields-operators-docs_pre_magic_removal.diff (1.3 kB) - added by eric@ericwalstad.com on 08/17/06 20:29:57.
The same patch back-ported to the pre-magic-removal tag (changeset r2808)

Change History

08/17/06 17:41:33 changed by Andy Dustman <farcepest@gmail.com>

  • attachment django-search_fields-operators.diff added.

Implementation

08/17/06 17:42:20 changed by Andy Dustman <farcepest@gmail.com>

  • summary changed from Operators for search_fields to [patch] Operators for search_fields.

08/17/06 18:08:50 changed by Andy Dustman <farcepest@gmail.com>

  • attachment django-search_fields-operators-docs.diff added.

Documentation

08/17/06 20:09:53 changed by eric@ericwalstad.com

  • attachment django-search_fields-operators_pre_magic_removal.diff added.

The same patch back-ported to the pre-magic-removal tag (changeset r2808)

08/17/06 20:29:57 changed by eric@ericwalstad.com

  • attachment django-search_fields-operators-docs_pre_magic_removal.diff added.

The same patch back-ported to the pre-magic-removal tag (changeset r2808)

08/17/06 21:48:35 changed by adrian

  • status changed from new to closed.
  • resolution set to fixed.

(In [3601]) Fixed #2559 -- Added cool new operators for Admin.search_fields, plus documentation. Thanks, Andy Dustman.

07/26/07 05:15:16 changed by QingFeng <paradise.qingfeng@gmail.com>

  • version set to SVN.

search_fields one filed multivalue search bug? http://code.djangoproject.com/ticket/4977


Add/Change #2559 ([patch] Operators for search_fields)




Change Properties
Action