Php 如何通过elastica在弹性搜索中查找字符串?
假设我想要一个搜索结果,每个项目的这个特定字段都有一个字符串,例如 标签 例如,我有一个名为description的数据字段,所以我想从结果中得到什么,只有那些在其描述中包含字符串“hashtag”的项,例如Php 如何通过elastica在弹性搜索中查找字符串?,php,
elasticsearch,elastica,Php,
elasticsearch,Elastica,假设我想要一个搜索结果,每个项目的这个特定字段都有一个字符串,例如 标签 例如,我有一个名为description的数据字段,所以我想从结果中得到什么,只有那些在其描述中包含字符串“hashtag”的项,例如 "the english alphabet has 28 letters #hashtag" 因此,上面带有此描述字段的项目应该包含在搜索结果中,因为描述字段值字符串中有一个hashtag字符串 如何在elastica中做到这一点?我应该使用什么过滤或函数?我知道如何使用这些php内置函
"the english alphabet has 28 letters #hashtag"
因此,上面带有此描述字段的项目应该包含在搜索结果中,因为描述字段值字符串中有一个hashtag字符串
如何在elastica中做到这一点?我应该使用什么过滤或函数?我知道如何使用这些php内置函数,但我说的是elasticsearch/ElasticCheck,它对您有帮助。
<?php
$mystring = 'abc';
$findme = 'a';
$pos = strpos($mystring, $findme);
// The !== operator can also be used. Using != would not work as expected
// because the position of 'a' is 0. The statement (0 != false) evaluates
// to false.
if ($pos !== false) {
echo "The string '$findme' was found in the string '$mystring'";
echo " and exists at position $pos";
} else {
echo "The string '$findme' was not found in the string '$mystring'";
}
?>