当前位置:网站首页>sphinx matches the specified field
sphinx matches the specified field
2022-08-05 08:39:00 【reg183】
In order to relieve the query pressure of the database, the data of the specified table is made into a sphinx index. Since the value of the field to be queried and other field values will be repeated, then I love programming to introduce the method of sphinx accurate query., friends in need can refer to:
1. Requirements:
There is a table in the database with 2 million pieces of data. Every time the spider crawls, the load of the database will be very high. Sphinx is often used for searching, and what I need to do isIt is necessary to accurately match the specified content, that is, to transfer the operation of querying the database to the use of sphinx.
Because the values of the ID and url fields of the data table will be repeated, we need to specify the fields here to achieve accurate query and display results.2. Solution:
(1), Set the search mode:
$sphinx->SetMatchMode(SPH_MATCH_EXTENDED2); (2), set the specified search field:$res_index = $sphinx->Query('@url' . $url, 'itbiancheng'); //itbiancheng is my index, here you need to replace it with your own according to the actual situation3. Verification result:
[total] => 1[total_found] => 1[time] => 0.000[words] => Array([42891] => Array([docs] => 2[hits] => 2))Although there are two hits shown here, according to the conditions we set above, only one will be displayed in the result4. SetMatchMode optional matching mode:
| Constant | Description |
|---|---|
| SPH_MATCH_ALL | Matches all query terms (default pattern). |
| SPH_MATCH_ANY | Matches any of the query terms. |
| SPH_MATCH_PHRASE | Consider the entire query as a phrase, requiring complete matches in order. |
| SPH_MATCH_BOOLEAN | Consider the query as a boolean expression. |
| SPH_MATCH_EXTENDED | Consider the query as an expression in Sphinx's internal query language. |
| SPH_MATCH_FULLSCAN | Use full scan, ignoring query terms. |
| SPH_MATCH_EXTENDED2 | Similar to SPH_MATCH_EXTENDED and supports scoring and weighting, the extended match mode allows the use of some conditional statements like mysql |
边栏推荐
- 让程序员崩溃的N个瞬间(非程序员误入)
- How to replace colors in ps, self-study ps software photoshop2022, replace one color of a picture in ps with another color
- 微信小程序请求封装
- ps怎么拼图,自学ps软件photoshop2022,PS制作拼图效果
- 吴恩达深度学习deeplearning.ai——第一门课:神经网络与深度学习——第二节:神经网络基础(下)
- 生命的颜色占卜
- JS syntax usage
- How to make a puzzle in PS, self-study PS software photoshop2022, PS make a puzzle effect
- 长期招聘嵌入式开发-深圳宝安
- Walk 100 trick society
猜你喜欢
![[Structural Internal Power Cultivation] The Mystery of Enumeration and Union (3)](/img/39/d20f45ccc86ebc4e5aebc8e4d0115f.png)
[Structural Internal Power Cultivation] The Mystery of Enumeration and Union (3)

php fails to write data to mysql
![[Structure internal power practice] Structure memory alignment (1)](/img/31/4ddc16810da8238ac95a93d007e12e.png)
[Structure internal power practice] Structure memory alignment (1)

Why is pnpm hitting npm and yarn dimensionality reduction?

接口全周期的生产力利器Apifox

MySQL 数据库 报错 The server quit without updating PID file (/var/lib/mysql/localhost.localdomain.pid)

D2--FPGA SPI接口通信2022-08-03

SVG Star Wars Style Toggle Toggle Button

Redis implements distributed lock-principle-detailed explanation of the problem

DataFrame insert row and column at specified position
随机推荐
最 Cool 的 Kubernetes 网络方案 Cilium 入门教程
P1160 队列安排
代码审计—PHP
Chapter 12 贝叶斯网络
Luogu P1966: [NOIP2013 提高组] 火柴排队 [树状数组+逆序对]
Thinking after writing a code with a very high CPU usage
Adb authorization process analysis
随机码的生成
JS语法使用
网络安全研究发现,P2E项目遭遇黑客攻击只是时间问题
512色色谱图
ps怎么替换颜色,自学ps软件photoshop2022,ps一张图片的一种颜色全部替换成另外一种颜色
DPU — 功能特性 — 存储系统的硬件卸载
[Structural Internal Power Cultivation] The Mystery of Enumeration and Union (3)
生命的颜色占卜
DPU — 功能特性 — 安全系统的硬件卸载
pnpm 是凭什么对 npm 和 yarn 降维打击的
SQL SERVER关于主从表触发器设计
写出了一个CPU占用极高的代码后引发的思考
星座理想情人