Django and full-text search

2019-03-27 01:07|来源: 网路

Structure in the flow » Blog Archive » Django and full-text search

Django and full-text search

Lately I’ve been searching for a simple solution for full-text Model search using Django. Every task up to this point just seemed so easy, so I was a bit surprised to discover there’s no quick, clean and preferred way to go about adding site search functionality in the framework.

So far, the information I read seems to suggest existing solutions are:

  • Based on a dedicated full-text search module
    • djangosearch
      • Supposed to become the official search contrib. Rather recent history (during 2008).
      • It’s an framework over existing, dedicated full text indexing engines:
    • django-sphinx
      • Wrapper around Sphinx full-text search engine
  • Based on a database engine full-text capability (ie. you must create full text indexes with appropriate DB commands)
    • For the MySQL backend, there’s already a “fieldname__search” syntax already supported in the framework, translating into a MATCH AGAINST query in SQL.
      • Supports basic boolean operators
      • Reference (look at the conclusion of the article)
    • For PostgreSQL, depending on the version of the engine, there are solutions, but they seem complex, relative to the MySQL approach
  • Most simple, but very inefficient: based on a simple LIKE %keyword% query
    • Uses the “fieldname__icontains” filter syntax
    • That’s what I used temporarily for get the feature going in my prototype

Other approaches are mentioned in this thread on StackOverflow.


转自:http://www.cnblogs.com/lexus/archive/2012/06/08/2541277

相关问答

更多
  • 不幸的是, 旧版索引已被弃用,此时没有替代方案。 我询问了将来实施此类功能的计划。 答案(@ chris.graphaware): 是的,它的计划是3.0或3.1。 另一方面,我倾向于说ES是用于搜索并且做得很好,当然它会为你的堆栈添加一个额外的层并关注一致性,但是,是的,一切都有代价:simple_smile: 基本上选项是: 遵循此处介绍的Neo4j 3.0+开发和结帐功能 探索将ElasticSearch作为搜索引擎集成到您的应用程序中的可能性(我相信GraphAware的人员可以为您提供此领域的内容 ...
  • 基本思想是从文本中构建索引作为列表属性(词干和删除停用词)。 要提高性能,请将list属性移动到子实体中,以使用“关系索引”。 这可以防止将可能很大的列表作为默认提取组的一部分加载 - 您只需要查询。 您将不得不使用低级别api来执行只有密钥查询才能返回父类的密钥,然后可以使用它来获取匹配的项目。 Basic idea is to build an index as a list property from the text (stemmed and with stop words removed). To ...
  • 它将取决于您的DBMS。 我相信大多数系统将不会利用全文索引,除非您使用全文函数。 (例如MSSQL中的MATCH / AGAINST或MS SQL中的FREETEXT / CONTAINS) 以下是有关SQL Server中何时,为什么以及如何使用全文索引的好文章: 了解SQL Server全文索引 It will depend upon your DBMS. I believe that most systems will not take advantage of the full-text inde ...
  • 我不明白这一点会影响你的速度。 你真的需要一个完整的外连接吗? 这是在杀你。 看起来这些表是一对一的。 在这种情况下,你不能让它成为内部连接吗? 你不能传递一个列表来包含像这样: SELECT mem.member_id, mem.contact_name, edu.member_id, edu.school_name FROM members mem INNER JOIN education edu ON edu.member_id = mem.member_id W ...
  • 我认为虽然sqlite是一个了不起的软件,但它的全文搜索功能非常有限。 相反,你可以使用Haystack Django app和一些像Elasticsearch这样的后端来索引你的数据库。 在我看来,这种设置(并且仍能访问您的sqlite数据库)在FTS方面是最强大和最灵活的方式。 Elasticsearch具有基于Levenshtein距离的模糊搜索 (简而言之,它将处理您的“egsample”查询)。 所以你需要的是做一个正确的查询类型: from haystack.forms import Searc ...
  • 我相信你在RelatedKeyword专栏中搜索完整的字符串Benjamin Franklin Quotes 你需要使用双引号来逃避单词之间的空格。 select * from quotestable where contains(RelatedKeyword, '"Benjamin Franklin Quotes"') I believe you are searching for the complete string Benjamin Franklin Quotes in RelatedKeyw ...
  • 是的, 确实如此 。 Yes, it does.
  • 你可以试试 Entry.objects.filter(headline__contains="search text") 或__icontains用于不区分大小写的搜索。 正如django doc所说__search现在只适用于MySQL。 You can try Entry.objects.filter(headline__contains="search text") or __icontains for case-insensitive search. As the django doc says ...
  • 如果您使用的是SQL Server 2008,则可以从运行中获得一些线索 SELECT * FROM sys.dm_fts_parser('FLOW AND VALVE',1033,0,0) SELECT * FROM sys.dm_fts_parser('"FLOW AND VALVE"',1033,0,0) CONTAINS( *, 'FLOW AND VALVE')被解释为两个与布尔条件连接在一起的搜索。 即CONTAINS( *, 'FLOW') AND CONTA ...
  • 这是MongoDB 2.4中存在的文本搜索的已知限制。 出于文本搜索的目的,MongoDB会将每个字符“ABCDEFGHIJKLMNOPQRSTUVWXYZ”(POSIX语言环境中设置的“大写”)与其小写等效字符相同,但它会将其他UTF-8代码点视为唯一。 UTF-8的完整案例折叠支持将在未来发布; 请参阅JIRA中的相关票证, 网址为https://jira.mongodb.org/browse/SERVER-8423 。 This is a known limitation of text search ...