Sphinx search engine, some quick questions

So, I'm just starting to read, I have never implemented a search in PHP before. I have a few questions that I was interested in:

  • By the sounds of things, does Sphinx need a 'daemon', a background program to work?
  • Let's say I built the index of mySQL table, then the user loads another record. In order to search to show this record, will I have to build the index again and again, every time the user updates / creates a record?

Thanks.

+3
source share
3 answers

, -. . , 1:00, 5 . , .

sql_query_killlist, , . .

conf .

source _user
{
    type = mysql
    sql_host = localhost
    sql_user = root
    sql_pass =
    sql_db = db
    sql_port = 3306
    sql_attr_uint = category_id
    sql_attr_timestamp = time_posted
}

source user_base : _user
{
    sql_query_pre = REPLACE INTO sphinx_lastrun (object_name, object_value) SELECT 'users', @max_stamp:=UNIX_TIMESTAMP(MAX(stamp))-1 FROM users
    sql_query = SELECT id, category_id, name, UNIX_TIMESTAMP(stamp) AS stamp FROM users WHERE stamp < FROM_UNIXTIME(@max_stamp)
    sql_query_info = SELECT id FROM users WHERE id=$id  
}

source user_incr : _user
{
    sql_query = SELECT id, category_id, name, UNIX_TIMESTAMP(stamp) AS stamp FROM users WHERE stamp >= (SELECT FROM_UNIXTIME(object_value) FROM sphinx_lastrun WHERE object_name = 'users')

    # You'll need sql_query_killlist to get rid of stuff that is deleted. See the docs

    sql_query_info = SELECT id FROM users WHERE id=$id      
}

index _user
{
    docinfo = extern
    mlock = 0
    morphology = none
    min_word_len = 2
    charset_type = sbcs
    min_prefix_len = 3
    enable_star = 1
}

index user_base : _user
{
    source = user_base
    path = /opt/sphinx/var/data/user_base
}

index user_incr : _user
{
    source = user_incr
    path = /opt/sphinx/var/data/user_incr
}

index user
{
    type = distributed
    local = user_base
    local = user_incr
}

searchd
{
    listen = 3312
    log = /opt/sphinx/var/log/searchd/searchd.log
    query_log = /opt/sphinx/var/log/searchd/query.log
    pid_file = /opt/sphinx/var/log/searchd/searchd.pid
}
+5

: , Sphinx , , .

+1

You can use an incremental indexing scheme, see here .

0
source

Source: https://habr.com/ru/post/1717710/


All Articles