etianen / django-watson

Full-text multi-table search application for Django. Easy to install and use, with good performance.
BSD 3-Clause "New" or "Revised" License
1.2k stars 130 forks source link

operator does not exist: text = uuid #214

Closed day009 closed 7 years ago

day009 commented 7 years ago

Hi! It works great except using filter:

class ItemConfig(AppConfig):
    name = 'item'

    def ready(self):
        Item = self.get_model("Item")
        watson.register(Item.objects.filter(is_published=True))

class Item(models.Model):

    id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
    item_nr = models.IntegerField(unique=True,)
    is_published = models.BooleanField(default=False)
    ...

Exception is:

operator does not exist: text = uuid LINE 1: ...= 'default' AND ("watson_searchentry"."object_id" IN (SELECT... HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) was the direct cause of the following exception:

Sorry if it is trivial issue.

etianen commented 7 years ago

What database are you using?

On Sun, 20 Aug 2017 at 20:36, day009 notifications@github.com wrote:

Hi! It works great except using filter:

class ItemConfig(AppConfig): name = 'item'

def ready(self):
    Item = self.get_model("Item")
    watson.register(Item.objects.filter(is_published=True))

class Item(models.Model):

id = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
item_nr = models.IntegerField(unique=True,)
...

Exception is:

operator does not exist: text = uuid LINE 1: ...= 'default' AND ("watson_searchentry"."object_id" IN (SELECT... HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) was the direct cause of the following exception:

Sorry if it is trivial issue.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/214, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCEHt_OUg_gBUqj5y7uazWXPFJvh4ks5saIqwgaJpZM4O8tQA .

day009 commented 7 years ago

It is Postgresql 9.5

etianen commented 7 years ago

Can I have the full traceback of your exception?

On 21 August 2017 at 12:44, day009 notifications@github.com wrote:

It is Postgresql 9.5

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/214#issuecomment-323722820, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCEMofT5dbUov1iR2s7qpOGOgpBBaks5saW2KgaJpZM4O8tQA .

day009 commented 7 years ago

Please inform if I should put here request/settings/other info also. views.py code is:

search_results = watson.search(search_term)
    for result in search_results:
print(result.title, result.url, result.meta.some_field)

Environment:

Request Method: POST Request URL: http://127.0.0.1:8000/en/search/

Django Version: 1.11.3 Python Version: 3.5.2 Installed Applications: ['django.contrib.auth', 'django.contrib.contenttypes', 'modeltranslation', 'grappelli', 'django.contrib.admin', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'mptt', 'tinymce', 'sorl.thumbnail', 'django_cleanup', 'adminsortable2', 'taggit', 'taggit_selectize', 'geoip2', 'captcha', 'pure_pagination', 'watson', 'corcc.apps.order.apps.OrderConfig', 'corcc.apps.image.apps.ImageConfig', 'corcc.apps.sitesetting.apps.SitesettingConfig', 'corcc.apps.item.apps.ItemConfig', 'corcc.apps.partner.apps.PartnerConfig', 'corcc.apps.search.apps.SearchConfig', 'corcc.apps.migration.apps.MigrationConfig', 'debug_toolbar'] Installed Middleware: ['django.middleware.common.BrokenLinkEmailsMiddleware', 'django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', 'django.middleware.locale.LocaleMiddleware', 'debug_toolbar.middleware.DebugToolbarMiddleware']

Traceback:

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return self.cursor.execute(sql, params)

The above exception (operator does not exist: text = uuid LINE 1: ...= 'default' AND ("watson_searchentry"."object_id" IN (SELECT... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts. ) was the direct cause of the following exception:

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner

  1. response = get_response(request)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = self.process_exception_by_middleware(e, request)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response

  1. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/yu/Documents/_projects/corcc_project/corcc/apps/item/views.py" in search

  1. for result in search_results:

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/models/query.py" in iter

  1. self._fetch_all()

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all

  1. self._result_cache = list(self._iterable_class(self))

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/models/query.py" in iter

  1. results = compiler.execute_sql(chunked_fetch=self.chunked_fetch)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql

  1. raise original_exception

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql

  1. cursor.execute(sql, params)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/debug_toolbar/panels/sql/tracking.py" in execute

  1. return self._record(self.cursor.execute, sql, params)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/debug_toolbar/panels/sql/tracking.py" in _record

  1. return method(sql, params)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return super(CursorDebugWrapper, self).execute(sql, params)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return self.cursor.execute(sql, params)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/utils.py" in exit

  1. six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/utils/six.py" in reraise

  1. raise value.with_traceback(tb)

File "/home/yu/.virtualenvs/corcc_dev/lib/python3.5/site-packages/django/db/backends/utils.py" in execute

  1. return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /en/search/ Exception Value: operator does not exist: text = uuid LINE 1: ...= 'default' AND ("watson_searchentry"."object_id" IN (SELECT... ^ HINT: No operator matches the given name and argument type(s). You might need to add explicit type casts.

etianen commented 7 years ago

Thanks for the detailed info! I've just pushed a fix to master that may solve your issue. Please let me know.

day009 commented 7 years ago

Works like a charm! Many thanks!

etianen commented 7 years ago

Just released 1.4.1!

On 22 August 2017 at 14:07, day009 notifications@github.com wrote:

Closed #214 https://github.com/etianen/django-watson/issues/214.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/etianen/django-watson/issues/214#event-1215873281, or mute the thread https://github.com/notifications/unsubscribe-auth/AAJFCCt4xrHJuwySe8J3TAIoEp0UBzo6ks5satKOgaJpZM4O8tQA .