扫一扫
分享文章到微信
扫一扫
关注官方公众号
至顶头条
作者:Martin Streicher 来源:论坛整理 2007年10月21日
关键字:
$ sudo /usr/local/bin/indexer --config /usr/local/etc/sphinx.conf --all Sphinx 0.9.7 Copyright (c) 2001-2007, Andrew Aksyonoff using config file '/usr/local/etc/sphinx.conf'... indexing index 'catalog'... collected 8 docs, 0.0 MB sorted 0.0 Mhits, 82.8% done total 8 docs, 149 bytes total 0.010 sec, 14900.00 bytes/sec, 800.00 docs/sec |
$ /usr/local/bin/search --config /usr/local/etc/sphinx.conf ENG Sphinx 0.9.7 Copyright (c) 2001-2007, Andrew Aksyonoff index 'catalog': query 'ENG ': returned 2 matches of 2 total in 0.000 sec displaying matches: 1. document=8, weight=1, assembly=5, model=7 id=8 partno=ENG088 description=Cylinder head price=55 2. document=9, weight=1, assembly=5, model=3 id=9 partno=ENG976 description=Large cylinder head price=65 words: 1. 'eng': 2 documents, 2 hits $ /usr/local/bin/search --config /usr/local/etc/sphinx.conf wind Sphinx 0.9.7 Copyright (c) 2001-2007, Andrew Aksyonoff index 'catalog': query 'wind ': returned 2 matches of 2 total in 0.000 sec displaying matches: 1. document=1, weight=1, assembly=3, model=1 id=1 partno=WIN408 description=Portal window price=423 2. document=5, weight=1, assembly=3, model=1 id=5 partno=WIN958 description=Windshield, front price=500 words: 1. 'wind': 2 documents, 2 hits $ /usr/local/bin/search \ --config /usr/local/etc/sphinx.conf --filter model 3 ENG Sphinx 0.9.7 Copyright (c) 2001-2007, Andrew Aksyonoff index 'catalog': query 'ENG ': returned 1 matches of 1 total in 0.000 sec displaying matches: 1. document=9, weight=1, assembly=5, model=3 id=9 partno=ENG976 description=Large cylinder head price=65 words: 1. 'eng': 2 documents, 2 hits |
<?php include('sphinx-0.9.7/api/sphinxapi.php'); $cl = new SphinxClient(); $cl->SetServer( "localhost", 3312 ); $cl->SetMatchMode( SPH_MATCH_ANY ); $cl->SetFilter( 'model', array( 3 ) ); $result = $cl->Query( 'cylinder', 'catalog' ); if ( $result === false ) { echo "Query failed: " . $cl->GetLastError() . ".\n"; } else { if ( $cl->GetLastWarning() ) { echo "WARNING: " . $cl->GetLastWarning() . ""; } if ( ! empty($result["matches"]) ) { foreach ( $result["matches"] as $doc => $docinfo ) { echo "$doc\n"; } print_r( $result ); } } exit; ?> |
$ sudo mkdir -p /var/log/searchd $ sudo /usr/local/bin/searchd --config /usr/local/etc/sphinx.conf $ php search.php 9 Array ( [fields] => Array ( [0] => partno [1] => description ) [attrs] => Array( [assembly] => 1 [model] => 1 ) [matches] => Array( [9] => Array( [weight] => 1 [attrs] => Array( [assembly] => 5 [model] => 3 ) ) ) [total] => 1 [total_found] => 1 [time] => 0.000 [words] => Array( [cylind] => Array( [docs] => 2 [hits] => 2 ) ) ) |
如果您非常迫切的想了解IT领域最新产品与技术信息,那么订阅至顶网技术邮件将是您的最佳途径之一。
现场直击|2021世界人工智能大会
直击5G创新地带,就在2021MWC上海
5G已至 转型当时——服务提供商如何把握转型的绝佳时机
寻找自己的Flag
华为开发者大会2020(Cloud)- 科技行者