0
votes

I have run into a problem with working sphinx configuration.

Data about configuration:

Sphinx 2.1.2-id64-release (r4245)

sphinx.conf source & index

source articles
{
    type                        = mysql
    sql_host                = localhost
    sql_user                = [x]
    sql_pass                = [x]
    sql_db                  = [x]
    sql_sock                = /var/run/mysqld/mysqld.sock

    sql_query = SELECT id, title, lead, body FROM articles
    sql_query_info      = SELECT * FROM articles WHERE id=$id
}

index articles
{

    source          = articles
    path            = /data/sphinx/var/data/articles
    docinfo         = extern
    mlock           = 0
    morphology      = none
    min_word_len        = 2
    charset_type        = utf-8
    charset_table         = 0..9, A..Z->a..z, _, a..z, U+410..U+42F->U+430..U+44F, U+430..U+44F, U+100->a,U+101->a,U+10C->c,U+10D->c,U+112->e,U+113->e,U+122->g,U+123->g,U+12A->i,U+12B->i,U+136->k,U+137->k,U+13B->l,U+13C->l,U+145->n,U+146->n,U+160->s,U+161->s,U+16A->u,U+16B->u,U+17D->z,U+17E->z
    min_prefix_len  = 2
    enable_star     = 1
    html_strip              = 1

}

The PHP that calls sphinx client looks like this:

$s = new SphinxClient;
$s->setServer("localhost", 3312);
echo $s->getLastError();
$s->setMatchMode(SPH_MATCH_ANY);
$s->setMaxQueryTime(3000);
$result['articles'] = $s->query($s->escapeString($_GET['s']), 'articles');

The sphinx configuration seems to be working and the query and sphinx log do not show any errors. In the output PHP script I also have this call which also outputs nothing. And there are no other PHP errors using E_ALL.

echo $s->getLastError();

Now, let's assume that there is an article with title A B (C D E), each letter being a word. ALL of the following queries have the article as 4th result in list:

A B (C D E)
A B (C D
A B (C
A B
A

At the same time, ALL of the following cannot find the article at all:

   B (C D E)
   B (C D
   B (C
   B
    *B
    *B*

Is this a feature of Sphinx?
I can't seem to find any mention that it should work like this, i.e. not being able to search by parts of sentence.
Is there a way to change this behaviour?
I looked at the match modes in the docs and tried out SPH_MATCH_EXTENDED, however, the results were even worse.

Thank you!

1
Please provide the actual words, not just letters.barryhunter

1 Answers

0
votes

It is definitely possible to do what you want. I did it in a project last year. Try "min_infix_len" here is the documentation: http://sphinxsearch.com/docs/archives/1.10/conf-min-infix-len.html

This should enable the feature you want. To search eg.g. in the text "i was in berlin when i" the word berlin.

Have fun