sphinx

mysqludf_json将关系数据以JSON编码

泪湿孤枕 提交于 2019-12-03 09:07:27
1. 前言 sphinx2.1版本引入了json属性,该如何构建json格式数据呢?mysql触发器与gearman结合应用时,只能向gearman worker传递单一的字符串参数,如果要将mysql表中的某些列的数据传递给worker处理呢?这些问题,在我工作当中遇到过的,后面再一一整理出来与大家分享。那么,这样将数据以json格式编码呢,下面先介绍下lib_mysqludf_json,后续会使用到这个UDF。 lib_mysqludf_json UDF库函数将关系数据映射为JSON格式。 通常,数据库中的数据映射为JSON格式,是通过程序来转换的。比如,PHP的json扩展,将PHP数据结构转换为JSON,这通常是需要遍历整个结果集后来创建JSON格式。使用UDF来进行JSON编码更快。 2. 通常用法说明 JSON UDFs在设计时考虑到在大部分情况下,只有一个简单和直接的映射是必须的。因此,JSON UDFs尽量简单的映射,尽量少的开销。不过,也能产生更复杂的映射。 2.1 lib_mysqludf_json提供的功能有: 1). 可变长度的参数列表允许直接映射 在很多情况下, 需要映射行级别数据为JSON数组或JSON对象。可变参数列表允许单一方法调用来接受一个完整的项目,随后被映射为JSON结构。 2). 字符串数据的正确转义 字符串值映射到JSON字符串时

Loading data from associated model in same query in rails

匿名 (未验证) 提交于 2019-12-03 08:54:24
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Basically, I have a Listing model, where each listing has a country id. I need the country name in my search results view. I know I can do @listing.country.name , but this performs an extra query for each listing in my search results. I'm using Thinking Sphinx, and in my controller I have @listings = Listing . search ( @ts_params ). page ( page_num ). per ( limit ) I have tried adding .includes(:countries) and variations thereof but no luck. What's the best way to go about this? I want the country data to be fetched in the same

'Unexpected Section Title' with Sphinx ― is numpy the issue?

匿名 (未验证) 提交于 2019-12-03 08:52:47
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: When running sphinx-build . html/ in my doc/ directory, I get the following output: $ sphinx-build . html/ Running Sphinx v0.6.4 No builder selected, using default: html loading pickled environment... done building [html]: targets for 0 source files that are out of date updating environment: 0 added, 1 changed, 0 removed reading sources... [100%] index reST markup error: HIDDEN/PATH/matplotlib_visualization.py:docstring of simulator.extensions.matplotlib_visualization.beta:20: (SEVERE/4) Unexpected section title. This file has numpy imports,

What is the Sphinx docstring standard for data structure types such as lists?

匿名 (未验证) 提交于 2019-12-03 08:44:33
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 由 翻译 强力驱动 问题: Does Sphinx have a supported standard for documenting the arguments or return value types that are not a simple, single object? For instance, in the following, arg1 is a str, arg2 is a list of str, and arg3 is either a str or int. How can you specify collection or composite types in Sphinx? Or is there no common standard for this? def function ( arg1 , arg2 , arg3 ): """ :param arg1: Argument 1 :type arg1: str :param arg2: Argument 2 :type arg2: list[str] :param arg3: Argument 3 :type arg3: str or int """ pass 回答1: Python 3.5 type

Sphinx/Solr/Lucene/Elastic Relevancy

匿名 (未验证) 提交于 2019-12-03 08:30:34
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: We have an extremely large database of 30+ Million products, and need to query them to create search results and ad displays thousands of times a second. We have been looking into Sphinx, Solr, Lucene, and Elastic as options to perform these constant massive searches. Here's what we need to do. Take keywords and run them through the database to find products that match the closest. We're going to be using our OWN algorithm to decide which products are most related to target our advertisements, but we know that these engines already have

Custom Syntax Highlighting with Sphinx

匿名 (未验证) 提交于 2019-12-03 07:36:14
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: I am interested in creating a custom syntax highlighter that can be used in a Sphinx environment. Is this possible? If so how would I go about doing it? 回答1: Background Sphinx ( http://sphinx-doc.org/ ) internally uses Pygments ( http://pygments.org/ ) as a syntax highligher. Pygments supports adding custom syntax highlighter (lexer) as described here http://pygments.org/docs/lexerdevelopment/ . Example usage I would try to define a new custom lexer in Pygments and initialize that new custom lexer in the conf.py sphinx configuration file. A

fwrite(): send of 8192 bytes failed with errno=104 Connection reset by peer

大兔子大兔子 提交于 2019-12-03 07:03:24
问题:fwrite(): send of 8192 bytes failed with errno=104 Connection reset by peer 问题描述 通过mysql + sphinx做的一个检索功能,之前一直没什么问题,最近检索时有部分检索失败,查看日志后报错为 fwrite(): send of 8192 bytes failed with errno=104 Connection reset by peer。 问题分析 查看代码部分,fwrite() 打开的资源为fsockopen(),通过fsockopen连接sphinx,将数据写入到sphinx服务端。 最终发现问题出在sphinx服务端,由于检索的数据太大,在请求sphinx服务端时,发送的包数据超过了sphinx可接受的最大值,导致以上问题。 解决方法 修改sphinx.conf中max_packet_size(最大允许的网络包大小)的设置值以解决问题。 来源: https://www.cnblogs.com/it-june/p/11782234.html

给全文搜索引擎Manticore (Sphinx) search 增加中文分词

纵饮孤独 提交于 2019-12-03 05:48:13
文章首发于我的技术博客:你可以在上面看到更多的 Python教程 和 python爬虫 Sphinx search 是一款非常棒的开源全文搜索引擎,它使用C++开发,索引和搜索的速度非常快,我使用sphinx的时间也有好多年了。最初使用的是coreseek,一个国人在sphinxsearch基础上添加了mmseg分词的搜索引擎,可惜后来不再更新,sphinxsearch的版本太低,bug也会出现;后来也使用最新的sphinxsearch,它可以支持几乎所有语言,通过其内置的ngram tokenizer对中文进行索引和搜索。 但是,像中文、日文、韩文这种文字使用ngram还是有很大弊端的: 当Ngram=1时,中文(日文、韩文)被分解成一个个的单字,就像把英文分解成一个个字母那样。这会导致每个单字的索引很长,搜索效率下降,同时搜索结果习惯性比较差。 当Ngram=2或更大时,会产生很多无意义的“组合”,比如“的你”、“为什”等,导致索引的 字典 、索引文件等非常大,同时也影响搜索速度。 基于以上弊端,为中日韩文本加入分词的tokenizer是很有必要的。 于是决定来做这件事。先去Sphinxsearch网站去看看,发现它已经发布了新的3.x版本,而且加入了很多很棒的特性,然而它从Sphinxsearch 3.x 开始,暂时 不再开源 . 不过

安装sphinx、coreseek

霸气de小男生 提交于 2019-12-03 05:48:03
wget http://sphinxsearch.com/files/sphinx-2.2.10-release.tar.gz tar -zxvf sphinx-2.2.10-release.tar.gz cd sphinx-2.2.10-release sh configure --prefix=/usr/local/sphinx make && make install wget http://www.coreseek.cn/uploads/csft/4.0/coreseek-4.1-beta.tar.gz tar -zxvf coreseek-4.1-beta.tar.gz cd coreseek-4.1-beta cd mmseg-3.2.14 sh configure --prefix=/usr/local/mmseg 如果报错config.status: error: cannot find input file: src/Makefile.in执行以下命令 aclocal libtoolize --force automake --add-missing autoconf autoheader make clean make && make install cd .. cd csft-4.1 sh buildconf.sh ./configure --prefix=

discuz论坛配置开启Sphinx全文搜索

孤人 提交于 2019-12-03 05:47:36
技术简介: Sphinx是一个基于SQL的全文检索引擎,可以结合MySQL,PostgreSQL做全文搜索,它可以提供比数据库本身更专业的搜索功能,使得应用程序更容易实现专业化的全文检索。Sphinx特别为一些脚本语言设计搜索API接口,如PHP,Python,Perl,Ruby等,同时为MySQL也设计了一个存储引擎插件。 Sphinx 单一索引最大可包含1亿条记录,在1千万条记录情况下的查询速度为0.x秒(毫秒级)。Sphinx创建索引的速度为:创建100万条记录的索引只需 3~4分钟,创建1000万条记录的索引可以在50分钟内完成,而只包含最新10万条记录的增量索引,重建 如果用到sphinx,全文索引交给sphinx来做,sphinx返回含有该word的ID号,然后用该ID号直接去数据库准确定位那些数据,整个过程如下图:一次只需几十秒。 因为sphinx默认不支持中文索引及检索,而coreseek基于sphinx开发了coreseek全文检索服务器,它提供了为sphinx设计的中文分词包libmmseg包含mmseg中文分词,是目前用的最多的sphinx中文检索。在没有sphinx之前,mysql数据库要对海量的文章中的词进行全文索引,一般用的语句例如:SELECT *** WHERE *** LIKE '%word%';这样的LIKE查询,并且再结合通配符%