当前位置: 首页 > news >正文

网页版微信登不上去怎么回事/某网站搜索引擎优化

网页版微信登不上去怎么回事,某网站搜索引擎优化,网站规划的任务,幼儿做爰网站很遗憾,haystack sphinx 没有文档可以查看,菜鸟们都安息了。还好有django-sphinx 。这玩意挺好!!!! 安装: django-sphinx , 这个现在已经是非常稳定的了,所以github上边也不会再有任…

很遗憾,haystack+ sphinx 没有文档可以查看,菜鸟们都安息了。还好有django-sphinx 。这玩意挺好!!!!

 安装:

django-sphinx  , 这个现在已经是非常稳定的了,所以github上边也不会再有任何新的发行版了,稳定才是最好的保障。所以直接pip install django-sphinx 安装吧

sphinx ,下载,我暂时使用的是稳定版的,0.9.9的,http://sphinxsearch.com/downloads/archive/ ,你根据自己需要下载啊,整完直接解压到d盘吧

         d:\sphinx

然后直接创建一个data文件夹 即d:\sphinx\data\ (在配置中使用的存储索引的地方)     

使用,这个超简单的,下面是官方的用法说明

from djangosphinx.models import SphinxSearchclass MyModel(models.Model):search = SphinxSearch() # 默认索引名是你的表名即model名
search = SphinxSearch('index_name') # 自己设定索引名
searchdelta = SphinxSearch(index='index_name delta_name',weights={                            #设定相关权重'name': 100,'description': 10,'tags': 80,},mode='SPH_MATCH_ALL',rankmode='SPH_RANK_NONE',)
#以上是在model中使用
#下面是在views.py中使用查询方法

queryset = MyModel.search.query('query')
results1 = queryset.order_by('@weight', '@id', 'my_attribute')
results2 = queryset.filter(my_attribute=5)
results3 = queryset.filter(my_other_attribute=[5, 3,4])
results4 = queryset.exclude(my_attribute=5)[0:10]
results5 = queryset.count()

下面介绍我在练习中使用的例子

from django.db import models
from djangosphinx.models import SphinxSearchclass Chang(models.Model):title=models.CharField(max_length=200)body=models.TextField()tags=models.CharField(max_length=200)search=SphinxSearch(index='sphinxtest_chang')

然后再view中使用

from model import Chang
from django.shortcuts import render_to_response
def
search(request):if request.method == 'POST':query=request.POST.get('query',None)r=Chang.search.query(query)chang=list(r)context={'chang':chang,'query':query,'search_meta':r._sphinx}else:chang=list()context={'chang':chang}return render_to_response('search/search.html',context)

再看我的templates\sphinxtest\search.html

<!DOCTYPE html>
<html>
<head><title></title>
</head>
<body>
<div><form action="/search/" method="POST"><input type="text" name="query"/><input type="submit"></form>{% if chang%}<p>Your search for &ldquo;<strong>{{ query }}</strong>&rdquo; had <strong>{{ search_meta.total_found }}</strong> results.</p><p>search_meta object dump: {{ search_meta }}</p>{% endif %}<hr/>{% for s in chang%}<h3>{{ s.title }}</h3><h4>{{s.body}}</h4><p>(weight: {{ s.sphinx.weight }})</p><p>story.sphinx object dump: {{ s.sphinx }}</p>{% endfor %}
</div>
</body>
</html>

最后看看我的settings.py

INSTALLED_APPS = (
   ...
'djangosphinx','sphinxtest',
...
) #Sphinx 0.9.9 SPHINX_API_VERSION = 0x116

和urls.py配置

 

urlpatterns = patterns('',
(r'^search/$','sphinxtest.views.search'), )

准备工作做完之后,我们开始创建索引吧

python manage.py generate_sphinx_config sphinxtest >> d:\sphinx\bin\sphinx.conf  
#这个本身sphinx.conf应该在d:\sphinx\下,我这样地址会创建一个新的,使用时也用他,不过这个是不完全的,建议直接参考d:\sphinx\下的sphinx-min.conf

直接上我的配置吧

source sphinxtest_chang
{type                = pgsqlsql_host            = 127.0.0.1sql_user            = postgressql_pass            = 1234sql_db              = changsql_port            = 5432sql_query_pre       = #SET NAMES utf8sql_query_post      =sql_query           = \SELECT id, title, body, tags\FROM sphinx_storysql_query_info      = SELECT * FROM `sphinx_story` WHERE `id` = $id
}index sphinxtest_chang
{source          = sphinxtest_changpath            = d:/sphinx/data/sphinxtest_changdocinfo         = externmorphology      = nonestopwords       =min_word_len    = 1charset_type    = utf-8charset_table   =  0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F #索引时用于转换大小写的字符表min_prefix_len  = 0min_infix_len   = 0ngram_len = 1 # 简单分词,只支持0和1,如果要搜索中文,请指定为1ngram_chars = U+3000..U+2FA1F # 需要分词的字符,如果要搜索中文,需设置此项
}indexer
{mem_limit                = 32M
}searchd
{port                    = 3312log                        = @CONFDIR@/log/searchd.logquery_log                = @CONFDIR@/log/query.logread_timeout            = 5max_children            = 30pid_file                = @CONFDIR@/log/searchd.pidmax_matches                = 1000seamless_rotate            = 1preopen_indexes            = 0unlink_old                = 1
}

 sphinx 创建索引

cd 到 d:\sphinx\bin\
indexer --config sphinx.conf sphinxtest_chang
开启sphinx服务
cd 到 d:\sphinx\bin\
searchd --config sphinx.conf
最后运行程序,查看结果吧,记得网数据库中添加点数据哦,否则你创建出的索引是搜不到结果的。

转载于:https://www.cnblogs.com/chang/archive/2013/01/10/2855355.html

http://www.lbrq.cn/news/1598959.html

相关文章:

  • 网站确定关键词 如何做/济南网站制作平台
  • 网站制作与网站设计/seo策略分析
  • 网站改版对seo的影响/google关键词挖掘工具
  • 建一个快讯网站要多少钱/seo资讯推推蛙
  • 网站建设 推广/怎么注册网站平台
  • 织梦制作网站如何上线/seo海外
  • 如何做网站链接分享朋友圈/线上营销渠道
  • 江苏建设信息网站有时候打不开/做推广的公司一般都叫什么
  • 网站换空间的流程/宣传网页制作
  • 网站网络推广/百度一下就知道手机版
  • 东莞网站建设关键词/外贸网站制作公司
  • 自己做网站的难度/西安小程序开发的公司
  • 桓台网站/星巴克seo网络推广
  • 苏州市网站制作/北京网站优化对策
  • 做外国网用哪些网站有哪些/注册网站域名
  • 公司做网站做什么类型的网站好/求网址
  • 加强意识形态建设 办好政协网站/网站维护工作内容
  • 贵州网站制作设计公司哪家好/怎么自己做一个网址
  • 群晖nas做网站服务器/安卓优化大师app下载安装
  • 合肥城乡建设网站首页/网络营销推广优化
  • 水车头采集wordpress内容/大侠seo外链自动群发工具
  • 动态网站开发实训总结/bt最佳磁力搜索引擎
  • wordpress调用相关文章/重庆公司seo
  • 做视频小网站犯法吗/德州seo整站优化
  • 英文外贸网站设计/数据分析师35岁以后怎么办
  • 山东省建设节能协会网站/net的网站建设
  • 日本r影片网站做我的奴隶/晚上看b站
  • 折扣券网站怎么做/山东最新消息今天
  • 怎样做营销型网站推广/流量平台有哪些
  • 做网站如何防止被坑/哈尔滨seo优化软件
  • 【web应用】前后端分离项目基本框架组成:Vue + Spring Boot 最佳实践指南
  • 【多智能体cooragent】CoorAgent 系统中 5 个核心系统组件分析
  • 部署 Kibana 8.2.2 可视化管理 Elasticsearch 8.2.2 集群
  • C++23 Concepts:用类型约束重构泛型编程的终极方案
  • 动态置信度调优实战:YOLOv11多目标追踪精度跃迁方案(附完整代码)
  • 【硬件-笔试面试题】硬件/电子工程师,笔试面试题-56,(知识点:电源模块,DCDC电源,LDO电源,原理及其特点)