Coolx World - Programming
sphinx 스핑크스 관련 각종 정보 (Java)
2019-05-21 18:23 - swindler
select * from sph_VIDEO where match('SearchQuery');

이렇게 검색하면 기본적으로 20개 결과만 나온다.
limit 0,50 과 같이 하면 결과를 더 얻을 수 있다.



select add1, add2, add3, address from sph_zip_code where match('운산');

이렇게 검색하면 "운" "산" 글자를 쪼개서 검색하기도 한다.
정확히 일치하는 단어가 점수가 높고, 점수순으로 정렬되는 것으로 추정된다.

'운산' - 운산, 산운, 운, 산 을 찾음
'"운산"' - 운산만 찾는다.

'충남운산' '충남 운산' '운산충남' '운산 충남'
모두 검색결과가 동일하다.


'"충남""운산"'
'"충남" "운산"'
'"운산" "충남"'
'"운산""충남"'

모두 검색결과가 동일하다.


'"충남"|"운산"'
충남 또는 운산 검색결과가 반환된다.


# address, add1 컬럼에서 운산 찾아라

MySQL [(none)]> select add1, add2, add3, address from sph_zip_code where match('@(address, add1) "운산"');




# address 컬럼 제외한 컬럼에서 운산 찾아라

MySQL [(none)]> select add1, add2, add3, address from sph_zip_code where match('@!address "운산"');



# address, add1 컬럼 제외한 컬럼에서 "운산" 또는 "서산" 찾아라

MySQL [(none)]> select add1, add2, add3, address from sph_zip_code where match('@!(address, add1) "운산""서산"');



아래와 같이 메모리 에러가 나는 경우가 있다.

FATAL: out of memory (unable to allocate 1342177284 bytes)

이 경우 indexer의 메모리를 늘려주면 된다.

indexer
{
mem_limit = 1024M
}



sql_attr_bigint = VIEW
sql_field_string = VID

Sphinx에서는 크게 2개의 타입이 있는데 Attribute와 Field다.

Attribute : Full-Text 기능 없음. 정렬, 필터 기능 있음.
Field : Full-Text 기능을 지원.




indexer 실행시에 다음과 같이 에러가 나는 경우가 있음

ERROR: index 'sph_VIDEO': sql_fetch_row: Lost connection to MySQL server during query.


mysql 에서 다음과 같이 설정을 변경함

show variables where variable_name like '%NET_READ_TIMEOUT%';
set global net_read_timeout = 3600;

show variables where variable_name like '%NET_WRITE_TIMEOUT%';
set global net_write_timeout = 3600;


Copyright © 1999-2020, swindler.

  2HLAB   2HLAB_Blog   RedToolBox   Omil   Omil_Blog