2017-03-21 5 views
0

내 mysql db에있는 문서를 기반으로 사전을 만들려면 sphinx 인덱서를 사용하고 있지만 소스의 sql 쿼리를 선택한 열로 제한 할 수는 없습니다. 스핑크스에서 소스의 sql 쿼리에서 열을 선택하는 방법

내가 development.sphinx.conf에서 다음 소스로

indexer --buildstops dict.txt 1000 --verbose --print-queries --dump-rows listing_rows --buildfreqs listing_core -c config/development.sphinx.conf 

를 사용하는 명령입니다, 어떤 문서를 찾을 수 없습니다와 dict.txt이 비어 있습니다

source listing_source { 
    type = mysql 
    sql_host = mysql 
    sql_user = sharetribe 
    sql_pass = secret 
    sql_db = sharetribe_development 
    sql_query = SELECT title AS title, description AS description FROM listings; 
} 

출력

Sphinx 2.2.10-id64-release (2c212e0) 
Copyright (c) 2001-2015, Andrew Aksyonoff 
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com) 

using config file 'config/development.sphinx.conf'... 
WARNING: key 'max_matches' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'charset_type' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'enable_star' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'charset_type' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'enable_star' was permanently removed from Sphinx configuration. Refer to documentation for details. 
indexing index 'listing_core'... 
building stopwords list... 
SQL-CONNECT: ok 
SQL-QUERY: SELECT title AS title, description AS description FROM listings;: ok 
total 0 docs, 0 bytes 
total 0.008 sec, 0 bytes/sec, 0.00 docs/sec 
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 

모든 열을 반환하도록 sql_query를 변경하면 인덱서에서 예상되는 문서 수를 찾습니다. (2) 사전에 추가합니다.

source listing_source { 
    type = mysql 
    sql_host = mysql 
    sql_user = sharetribe 
    sql_pass = secret 
    sql_db = sharetribe_development 
    sql_query = SELECT * FROM listings; 
} 

출력 :

Sphinx 2.2.10-id64-release (2c212e0) 
Copyright (c) 2001-2015, Andrew Aksyonoff 
Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com) 

using config file 'config/development.sphinx.conf'... 
WARNING: key 'max_matches' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'charset_type' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'enable_star' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'charset_type' was permanently removed from Sphinx configuration. Refer to documentation for details. 
WARNING: key 'enable_star' was permanently removed from Sphinx configuration. Refer to documentation for details. 
indexing index 'listing_core'... 
building stopwords list... 
SQL-CONNECT: ok 
SQL-QUERY: SELECT * FROM listings;: ok 
total 2 docs, 485 bytes 
total 0.008 sec, 56303 bytes/sec, 232.18 docs/sec 
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg 

은 어떻게 선택 컬럼 만 반환하는 쿼리를 제한 할 수 있습니다?

답변

1

sql_query = SELECT 제목 AS 제목, 설명 AS 설명 FROM listings;

document_id가 없기 때문에 작동하지 않습니다. id 열을 추가하십시오 (첫 번째 열로!) 작동해야합니다. 같은 이름을 사용하는 경우 'AS'가 필요하지 않습니다. 열 같은 ID가 먼저하는 일이 있기 때문에 (* 아마, 일 :

... 그러니 그냥 확인이 ID를 포함하게 한 다음 열 필드으로 사용할 이름을

sql_query = SELECT id, title, description FROM listings 
관련 문제