企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持知识库和私有化部署方案 广告
# Swish(实验性) Swish-e是GPL许可的搜索引擎,Swish-e代表“人类的简单Web索引系统-增强”,并且是用于索引和搜索的开源系统。Swish-e本身已获得GPL许可证的许可,其子句允许应用程序 链接到libswish-e库,以使用已发布的API来执行此操作, 而无需调用GPL的病毒式部分。这需要将 链接返回到swish-e源代码。 它在这里: <http://swish-e.org> 该软件包未维护 <https://pecl.php.net/package/swish>. - [Swish :: \_\_ construct](https://www.php.net/manual/en/swish.construct.php)—构造一个Swish对象 - [Swish :: getMetaList](https://www.php.net/manual/en/swish.getmetalist.php)—获取索引的元条目列表 - [Swish :: getPropertyList](https://www.php.net/manual/en/swish.getpropertylist.php)—获取索引的属性列表 - [Swish :: prepare](https://www.php.net/manual/en/swish.prepare.php)—准备搜索查询 - [Swish :: query](https://www.php.net/manual/en/swish.query.php)—执行查询并返回结果对象 - [SwishResult :: getMetaList](https://www.php.net/manual/en/swishresult.getmetalist.php)—获取元条目列表 - [SwishResult :: stem](https://www.php.net/manual/en/swishresult.stem.php)—[阻止](https://www.php.net/manual/en/swishresult.stem.php)给定的单词 - [SwishResults :: getParsedWords](https://www.php.net/manual/en/swishresults.getparsedwords.php)—获取已解析单词的数组 - [SwishResults :: getRemovedStopwords](https://www.php.net/manual/en/swishresults.getremovedstopwords.php)—获取从查询中删除的停用词数组 - [SwishResults :: nextResult](https://www.php.net/manual/en/swishresults.nextresult.php)—获取下一个搜索结果 - [SwishResults :: seekResult](https://www.php.net/manual/en/swishresults.seekresult.php)—将当前[搜寻](https://www.php.net/manual/en/swishresults.seekresult.php)指针设置为给定位置 - [SwishSearch :: execute](https://www.php.net/manual/en/swishsearch.execute.php)—执行搜索并获取结果 - [SwishSearch :: resetLimit](https://www.php.net/manual/en/swishsearch.resetlimit.php)—重置搜索限制 - [SwishSearch :: setLimit](https://www.php.net/manual/en/swishsearch.setlimit.php)—设置搜索限制 - [SwishSearch :: setPhraseDelimiter](https://www.php.net/manual/en/swishsearch.setphrasedelimiter.php)—设置短语定界符 - [SwishSearch :: setSort](https://www.php.net/manual/en/swishsearch.setsort.php)—设置排序顺序 - [SwishSearch :: setStructure](https://www.php.net/manual/en/swishsearch.setstructure.php)—在搜索对象中设置结构标志 例子 ``` <pre class="calibre17">``` <span class="token5">try</span> <span class="token3">{</span> $swish <span class="token1">=</span> <span class="token5">new</span> <span class="token4">Swish</span><span class="token3">(</span><span class="token2">"index.swish-e"</span><span class="token3">)</span><span class="token3">;</span> $results <span class="token1">=</span> $swish<span class="token1">-</span><span class="token1">></span><span class="token4">query</span><span class="token3">(</span><span class="token2">"test OR text"</span><span class="token3">)</span><span class="token3">;</span> echo <span class="token2">"Found "</span><span class="token3">,</span> $results<span class="token1">-</span><span class="token1">></span>hits<span class="token3">,</span> <span class="token2">" results\n"</span><span class="token3">;</span> <span class="token5">while</span> <span class="token3">(</span>$result <span class="token1">=</span> $results<span class="token1">-</span><span class="token1">></span><span class="token4">nextResult</span><span class="token3">(</span><span class="token3">)</span><span class="token3">)</span> <span class="token3">{</span> <span class="token4">var_dump</span><span class="token3">(</span>$result<span class="token3">)</span><span class="token3">;</span> <span class="token5">break</span><span class="token3">;</span> <span class="token">//break after the first result</span> <span class="token3">}</span> <span class="token3">}</span> <span class="token5">catch</span> <span class="token3">(</span><span class="token4">SwishException</span> $e<span class="token3">)</span> <span class="token3">{</span> echo <span class="token2">"Error: "</span><span class="token3">,</span> $e<span class="token1">-</span><span class="token1">></span><span class="token4">getMessage</span><span class="token3">(</span><span class="token3">)</span><span class="token3">,</span> <span class="token2">"\n"</span><span class="token3">;</span> <span class="token3">}</span> ``` ```