Question

I'am trying to use sphinx search to provide keyword search feature to a web application i'am working on.

I have tried everything to get the numeric and alpha-numeric search to work, but found no luck! (tried to configure sphinx.conf using charset_table, index_exact_words, infix, substring).

Here is the sphinx.conf file settings:

source src1 : base_src
{
    sql_query          = SELECT CRC32(string_field1) AS id, 1 AS table_id, \
       string_field1, string_field2, string_field3, string_field4, string_field5 \
       FROM table1
    sql_query_info     = SELECT * FROM table1 WHERE CRC32(string_field1)=$id
    sql_attr_uint      = table_id
    sql_attr_string    = string_field1
}

index idx1
{
    morphology          = stem_en
    max_substring_len   = 0
    min_infix_len       = 1
    enable_star         = 1
    expand_keywords     = 1
    dict                = keywords
    mlock               = 0
    min_word_len        = 1
    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
    index_exact_words   = 1
    source              = src1
    path                = /home/{myUserName}/indices/idx1
}

here string_field1 is an alpha-numeric string.

Example:

string_field1 = "HMGC_GL0000047"

$sphinx->query('GL0', 'idx1');

or

$sphinx->query('047', 'idx1');

how to configure and use sphinx + php to make the numeric and alpha-numeric search work?

Was it helpful?

Solution

You've defined string_field1 as an attribute, with sql_attr_string.

Because its an Attribute, it's NOT full-text indexed. So it will never match any keywords in the search.

Fields on the other hand ARE indexed, and would match. Anything not defined as an attribute, and never the first column in sql_query, but everything else will be a field.

So can either remove sql_attr_string if you diddnt really want it to work as an attribute. Or can use sql_field_string, to make the column BOTH a field and attribute. Once you string_field1 defined as a feild, it should match on your query.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top