我正在尝试将Sphinx搜索引擎与他们的Python API一起使用.安装顺利.但是当我使用他们的Python API时,我没有得到完整的结果集.我只收到身份证?但是当我在./bin中使用他们的./search二进制文件时,我得到了整个索引内容.
使用cpp ./search binary时 -
./search test
1. document=1, weight=1, group_id=1, date_added=Sat Sep 11 07:42:38 2010, title=2
id=1
group_id=1
group_id2=5
date_added=2010-09-11 07:42:38
title=test one
content=this is my test document number one. also checking search within phrases.
Run Code Online (Sandbox Code Playgroud)
但是当我使用Python API时,我得到 -
>>> import sphinxapi
>>> client = sphinxapi.SphinxClient()
>>> client.SetServer('127.0.0.1', 9312)
>>> client.Query('test')
{'status': 0, 'matches': [{'id': 1, 'weight': 1, 'attrs': {'date_added': 1284171158, 'group_id': 1, 'title': 2}}, {'id': 2, 'weight': 1, 'attrs': {'date_added': 1284171158, 'group_id': 1, 'title': 3}}, {'id': 4, …
Run Code Online (Sandbox Code Playgroud) 我在Sphinx 2.0.6中尝试启用通配符(*)时遇到以下错误
索引产品:语法错误,'*'附近的意外$ undefined
我的搜索字词是 iphone 4s*
它使用如下定义的产品索引.
index users
{
enable_star = 1
docinfo = extern
morphology = stem_en
charset_table = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F
ignore_chars = U+0021..U+002F,U+003A..U+003F,U+0060
charset_type = utf-8
html_strip = 0
source = gdgt_user
path = /var/lib/sphinxsearch/data/gdgt/users
min_infix_len = 3
min_word_len = 3
}
index products : users
{
enable_star = 1
min_infix_len = 1
min_word_len = 1
source = gdgt_products
path = /var/lib/sphinxsearch/data/gdgt/products
}
Run Code Online (Sandbox Code Playgroud)
我正在使用可以在源tar球中找到的php api.使用搜索CLI时,我能够看到错误.
search -c app/config/sphinx.compiled.conf -i products -e "ipho*" …
Run Code Online (Sandbox Code Playgroud) 我只是设置了django-sphinx,它工作得很漂亮.我现在能够搜索我的模型并获得惊人的结果.一个问题是我必须使用indexer命令手动构建索引.这意味着每次添加新内容时,我都必须手动命中命令行来重建搜索索引.这是不可接受的.
我可以创建一个自动运行索引器命令的cron作业,但这远非最佳.在cron再次运行之前,不会对新数据编制索引.此外,索引器将大多数时间不必要地运行,因为我的站点没有经常添加数据.
如何设置它,以便只要在可搜索的django模型中添加或修改数据,Sphinx索引就会自动重建?
django-sphinx文档显示django-sphinx层还支持对多个索引进行一些基本查询.
http://github.com/dcramer/django-sphinx/blob/master/README.rst
from djangosphinx.models import SphinxSearch
SphinxSearch('index1 index2 index3').query('hello')
Run Code Online (Sandbox Code Playgroud)
似乎SphinxSearch不包含函数query().我还尝试在spinx.conf sql_query配置中包含content_type,如django-sphinx文档中所述.没有任何效果.
Traceback (most recent call last):
File "<console>", line 1, in <module>
AttributeError: 'SphinxSearch' object has no attribute 'query'
Run Code Online (Sandbox Code Playgroud)
任何人都可以了解如何从sphinx中的多个索引中获得排名结果
我正在扩展django的用户模型.
from django.contrib.auth.models import User
class UserProfile(models.Model):
user = models.OneToOneField(User, _(u"User"))
Run Code Online (Sandbox Code Playgroud)
那么,是否可以在用户字段中使用db_index = True和unique = True?然后我需要通过用户名实现搜索.我想到了狮身人面像.有什么想法吗?也许有一些很好的教程链接?TIA