- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在使用 Django 2.0 和 postgresql 9.6
我已经在我的应用程序(文章)中创建并清空了迁移文件,其中包含以下内容以添加 unaccent 和 trigram 扩展
# Generated by Django 2.0 on 2018-02-06 22:34
from django.db import migrations
from django.contrib.postgres.operations import UnaccentExtension, TrigramExtension
class Migration(migrations.Migration):
dependencies = [
('articles', '0012_auto_20180205_2234'),
]
operations = [
UnaccentExtension(),
TrigramExtension()
]
然后我尝试运行以下查询:
from django.contrib.postgres.search import SearchQuery, SearchRank, SearchVector
vector = SearchVector('title',config='unaccent', weight='A') + SearchVector('description',config='unaccent', weight='B')
query = SearchQuery('india')
Article.objects.annotate(rank=SearchRank(vector, query)).filter(rank__gte=0.3).order_by('rank')
ProgrammingError: text search configuration "unaccent" does not exist
LINE 1: ...rticle"."qa_bool", ts_rank((setweight(to_tsvector('unaccent'...
最佳答案
我认为您的迁移文件没有在您的数据库中创建指定的 PostgreSQL 扩展。
也许您的数据库用户没有 super 用户权限。
Django 文档在 Creating extension using migrations 部分对其进行了解释:
Creating the extension requires a database user with superuser privileges. If the Django database user doesn’t have superuser privileges, you’ll have to create the extension outside of Django migrations with a user that has the appropriate privileges. In that case, connect to your Django database and run the query
CREATE EXTENSION IF NOT EXISTS hstore;
我再次阅读了您的代码,我认为问题在于 config='unaccent'
您不能将 unaccent
用作配置,但您必须传递一种语言 ( es: '意大利语') 或 '简单'
关于Django 全文搜索 : says unaccent does not exist,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48656231/
我在 Text::Unaccent 模块中遇到了一些奇怪的、与系统相关的问题。如果我遗漏了一些愚蠢的东西,我深表歉意,但我一直在用头撞这个几个小时,但没有真正的进展。 我有一个简单的脚本设置,可以很好
我有下表: CREATE TABLE products ( id bigserial NOT NULL PRIMARY KEY, name varchar(2048) -- Many
当我尝试安装 unaccent Postgres 扩展(通过 postgresql-contrib 包)时,一切都按以下方式运行: # psql -U postgres -W -h localhost
大家好,我有一个西类牙语医学术语数据库。假设表 description 有一个名为 term 的列。如果我使用以下查询: SELECT * FROM description WHERE unaccen
我正在使用 Django 2.0 和 postgresql 9.6 我已经在我的应用程序(文章)中创建并清空了迁移文件,其中包含以下内容以添加 unaccent 和 trigram 扩展 # Gene
我想从导入到 PostgreSQL 9.3.5 的 OpenStreetMap 数据库中检索具有给定名称的道路,操作系统是 Win7 64 位。为了有点容错,我使用了 Postgres 的 unacc
我使用 PostgreSQL 10 并运行 CREATE EXTENSION unaccent;成功。我有一个包含以下内容的 plgsql 函数whereText := 'lower(unaccent
表格学校 id | address | name 1 | Rybničná 59, Bratislava | Stredná odborná škola elektr
我有一个关于如何在 Grails 中使用 PostgreSQL 的 unaccent 扩展的问题。 我有很多法语描述,而且 PostgreSQL 不区分重音。我安装了 unaccent 扩展,它在 P
UNACCENT 函数可以去掉字符的变音符号。但是,就我而言,它只能去除带有 1 个变音符号的字符,例如 陈 超人 啊啊 对于具有超过 1 个变音符号的字符,UNACCENT 不执行任何操作,例如 呼
我正在尝试将 PostgreSQL 配置为在我的 Rails 应用程序中使用全文搜索,如本 Railscast 中所述. 我正在使用新的 Ubuntu 12.04 服务器运行 PostgreSQL 9
我必须比较查询中的两个字符串,如下所示: SELECT * FROM MY_TABLE WHERE column LIKE '%keyword%'; 但我想比较列和关键字的非重音值。 MySQL 中是
我在 Postgres 中安装了 unaccent 扩展,并且简单的过滤器在我的 Django 应用程序中运行良好,例如: q = 'hello' queryset.filter(name__unac
我在 postgresql 数据库上创建了扩展名“unaccent”,但是当我使用“unaccent”运行选择时,它总是返回 1 行,但有一个空行。 select ts_lexize('unaccen
我正在制作一个存储图书信息的 Postgres 表。我有一个手动输入数据的“标题”列,但我想创建一个自动生成的列“title_no_diacritics”,它使用 Unaccent 扩展名从标题中去除
在一个工作的应用程序中,我正在尝试实现无重音查询。 pg-gem version 0.21 postgresql version 9.5/9.6 rails version 4 我首先在此处创建/启用
在我们的 RoR 项目中,我们使用 postgres unaccent 函数来检索我们模型名称属性之一的非重音版本。 name 属性可以包含来自各种语言的任何重音字符。然后我们将其保存为 unacce
我们正在做一个项目,我们正在使用 Django 1.10a1,我们正在使用带有 PostgreSQL 的 Django 全文搜索,但我们需要使用 unaccent。 所以,我有这段代码:
我收到 FieldError: Unsupported Lookup 'unaccent' for CharField or join on the field not allowed。任何帮助表示赞
如何使用 Sequel.full_text_search 方法?与 PostgreSQL unaccent 中可用的函数相结合,以便返回与搜索词匹配的记录,而不考虑带有重音符号的字符? 例如: # G
我是一名优秀的程序员,十分优秀!