资源简介
基于sphinx的中文检索Sphinx如果需要对中文进行全文
检索,也得需要一些插件来补充。其中我知道的插件有 coreseek
代码片段和文件信息
#
# $Id: sphinxapi.py 2055 2009-11-06 23:09:58Z shodan $
#
# Python version of Sphinx searchd client (Python API)
#
# Copyright (c) 2006-2008 Andrew Aksyonoff
# Copyright (c) 2006 Mike Osadnik
# All rights reserved
#
# This program is free software; you can redistribute it and/or modify
# it under the terms of the GNU General Public License. You should have
# received a copy of the GPL license along with this program; if you
# did not you can find it at http://www.gnu.org/
#
import sys
import select
import socket
import re
from struct import *
# known searchd commands
SEARCHD_COMMAND_SEARCH = 0
SEARCHD_COMMAND_EXCERPT = 1
SEARCHD_COMMAND_UPDATE = 2
SEARCHD_COMMAND_KEYWORDS= 3
SEARCHD_COMMAND_PERSIST = 4
# current client-side command implementation versions
VER_COMMAND_SEARCH = 0x116
VER_COMMAND_EXCERPT = 0x100
VER_COMMAND_UPDATE = 0x101
VER_COMMAND_KEYWORDS = 0x100
# known searchd status codes
SEARCHD_OK = 0
SEARCHD_ERROR = 1
SEARCHD_RETRY = 2
SEARCHD_WARNING = 3
# known match modes
SPH_MATCH_ALL = 0
SPH_MATCH_ANY = 1
SPH_MATCH_PHRASE = 2
SPH_MATCH_BOOLEAN = 3
SPH_MATCH_EXTENDED = 4
SPH_MATCH_FULLSCAN = 5
SPH_MATCH_EXTENDED2 = 6
# known ranking modes (extended2 mode only)
SPH_RANK_PROXIMITY_BM25 = 0 # default mode phrase proximity major factor and BM25 minor one
SPH_RANK_BM25 = 1 # statistical mode BM25 ranking only (faster but worse quality)
SPH_RANK_NONE = 2 # no ranking all matches get a weight of 1
SPH_RANK_WORDCOUNT = 3 # simple word-count weighting rank is a weighted sum of per-field keyword occurence counts
# known sort modes
SPH_SORT_RELEVANCE = 0
SPH_SORT_ATTR_DESC = 1
SPH_SORT_ATTR_ASC = 2
SPH_SORT_TIME_SEGMENTS = 3
SPH_SORT_EXTENDED = 4
SPH_SORT_EXPR = 5
# known filter types
SPH_FILTER_VALUES = 0
SPH_FILTER_RANGE = 1
SPH_FILTER_FLOATRANGE = 2
# known attribute types
SPH_ATTR_NONE = 0
SPH_ATTR_INTEGER = 1
SPH_ATTR_TIMESTAMP = 2
SPH_ATTR_ORDINAL = 3
SPH_ATTR_BOOL = 4
SPH_ATTR_FLOAT = 5
SPH_ATTR_BIGINT = 6
SPH_ATTR_MULTI = 0X40000000L
SPH_ATTR_TYPES = (SPH_ATTR_NONE
SPH_ATTR_INTEGER
SPH_ATTR_TIMESTAMP
SPH_ATTR_ORDINAL
SPH_ATTR_BOOL
SPH_ATTR_FLOAT
SPH_ATTR_BIGINT
SPH_ATTR_MULTI)
# known grouping functions
SPH_GROUPBY_DAY = 0
SPH_GROUPBY_WEEK = 1
SPH_GROUPBY_MONTH = 2
SPH_GROUPBY_YEAR = 3
SPH_GROUPBY_ATTR = 4
SPH_GROUPBY_ATTRPAIR = 5
class SphinxClient:
def __init__ (self):
“““
Create a new client object and fill defaults.
“““
self._host = ‘localhost‘ # searchd host (default is “localhost“)
self._port = 9312 # searchd port (default is 9312)
self._path = None # searchd unix-domain socket path
self._socket = None
self._offset = 0 # how much records to seek from result-set start (default is 0)
self._limit = 20 # how much records to return from result-set starting at offset (default is 20)
self._mode = SPH_MATCH_ALL # query matching mode (default is SPH_MAT
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
文件 1756 2011-01-12 17:22 test.cmd
文件 46 2011-01-12 15:43 test_cjk.cmd
文件 72 2011-01-12 18:05 test_mysql.cmd
文件 57 2011-01-12 15:54 test_python.cmd
文件 5 2017-11-20 17:12 新建文本文档.txt
目录 0 2011-01-12 15:07 api\
目录 0 2011-01-12 15:07 api\java\
文件 545 2010-05-07 01:07 api\java\Makefile
文件 52 2010-05-07 01:07 api\java\MANIFEST.MF
文件 84 2010-05-07 01:07 api\java\mk.cmd
文件 22 2010-05-07 01:07 api\java\mkdoc.cmd
文件 725 2010-05-07 01:07 api\java\README
文件 38821 2010-05-07 01:07 api\java\SphinxClient.java
文件 482 2010-05-07 01:07 api\java\SphinxException.java
文件 618 2010-05-07 01:07 api\java\SphinxMatch.java
文件 1591 2010-05-07 01:07 api\java\SphinxResult.java
文件 652 2010-05-07 01:07 api\java\SphinxWordInfo.java
文件 6481 2010-05-07 01:07 api\java\test.java
目录 0 2011-01-12 15:07 api\libsphinxclient\
文件 1173 2010-05-07 01:07 api\libsphinxclient\build.mk
文件 640 2010-05-07 01:07 api\libsphinxclient\buildconf.sh
文件 42037 2010-05-07 01:07 api\libsphinxclient\config.guess
文件 30221 2010-05-07 01:07 api\libsphinxclient\config.sub
文件 652088 2010-05-07 01:07 api\libsphinxclient\configure
文件 1648 2010-05-07 01:07 api\libsphinxclient\configure.in
文件 25276 2010-05-07 01:07 api\libsphinxclient\COPYING
文件 9206 2010-05-07 01:07 api\libsphinxclient\install-sh
文件 3571 2010-05-07 01:07 api\libsphinxclient\libsphinxclient.vcproj
文件 183730 2010-05-07 01:07 api\libsphinxclient\ltmain.sh
文件 335 2010-05-07 01:07 api\libsphinxclient\Makefile.am
文件 19806 2010-05-07 01:07 api\libsphinxclient\Makefile.in
............此处省略145个文件信息
评论
共有 条评论