Sphinx全文搜索无法按预期工作

时间:2016-02-15 17:15:25

标签: postgresql laravel full-text-search sphinx

我在sphinx上遇到奇怪的问题,应该对表格中的单个列进行全文搜索。它会返回某些值的结果,但对于某些值,它不会返回任何值。

据我所知,我在Postgres(源代码)中有“贝尔格莱德”字样,查询“狮身人面像”的狮身人面像将不会给我任何结果。但如果我查询“贝尔格莱德”,它将返回结果。

它还会返回以搜索词结尾的单词,但如果搜索词位于单词的中间,则不会返回。

这是我的狮身人面像:

source src_cities
{
  type          = pgsql

  sql_host      = ####
  sql_user      = ####
  sql_pass      = ####
  sql_db        = ####
  sql_port      = 5432

  sql_query_pre = SET CLIENT_ENCODING TO 'UTF8';
  sql_query_pre = SET NAMES 'UTF8';

  sql_query     = \
  SELECT id,name \
  FROM cities

  sql_field_string = name

  sql_query_info        = SELECT * FROM cities WHERE id=$id
}
index cities
{
  source            = src_cities
  path              = /var/lib/sphinxsearch/data/cities
  docinfo           = extern
  charset_type      = sbcs
  min_word_len      = 1

}

以下是我试图从Laravel获取数据的方法:

$results = $sphinx->search($name, 'cities')
            ->setMatchMode(\Sphinx\SphinxClient::SPH_MATCH_EXTENDED)
            ->query();

1 个答案:

答案 0 :(得分:1)

这个帖子是相关的:

http://sphinxsearch.com/forum/view.html?id=3795

#include "PidController.h"

PidController::PidController():ControllerObject()
{
    m_errPrev[0] = 0;
    m_errPrev[1] = 0;
    m_outPrev = 0;
}
void PidController::UpdateParams(double kp, double ki, double kd)
{
    m_kp = kp;
    m_ki = ki;
    m_kd = kd;
}
//calculates PID output 
//y - sample of y(t)
//returns sample of u(t)
double PidController::sim(double y)
{
    double out; //u(t) sample
    double e = m_setPoint - y; //error
    out = m_outPrev + m_kp * (e - m_errPrev[0] + m_kd * (e - 2 * m_errPrev[0] + m_errPrev[1]) + m_ki * e);

    m_outPrev = out; //store previous output
    //store previous errors
    m_errPrev[1] = m_errPrev[0];
    m_errPrev[0] = e;

    return out;
}