Scandal
Well-known member
Hello all!
I have the following issue for which I need some help.
I have this part of code to make a search for nodes (I use also Enhanced Search / Elastic Search).
What I need to do?
On xf_forum db table (entity XF:Forum / not XF:Node), I have a text column, let's call it "title_new".
I need via the same search code, to detect the $nodeIds which are closer to $keywords, by search the xf_forum "title_new" column.
I know that I could made it with a finder->where LIKE %%, but currently I need to use the elastic search and maybe to do the search via the same $query.
As you know xf_forum and xf_node are joined via the node_id column.
Any idea?
If I need to make indexable my "title_new" column, some instructions would be very helpful!
I have the following issue for which I need some help.
I have this part of code to make a search for nodes (I use also Enhanced Search / Elastic Search).
PHP:
$input = [
'search_type' => 'node',
'keywords' => $keywords,
'c' => [],
'c.title_only' => 1,
'c.newer_than' => 0,
'c.older_than' => 0,
'c.users' => '',
'c.content' => '',
'c.type' => 'node',
'c.thread_type' => '',
'grouped' => false,
'order' => 'relevance'
];
$constraints = [];
$searchRequest = new \XF\Http\Request($this->app->inputFilterer(), $input, [], []);
$urlConstraints = $input['c'];
$searcher = $this->app()->search();
$query = $searcher->getQuery();
if ($input['search_type'] && $searcher->isValidContentType($input['search_type']))
{
$typeHandler = $searcher->handler($input['search_type']);
$query->forTypeHandler($typeHandler, $searchRequest, $urlConstraints);
}
$input['keywords'] = $this->app->stringFormatter()->censorText($input['keywords'], '');
if ($input['keywords'])
{
$query->withKeywords($input['keywords'], $input['c.title_only']);
}
$searchRepo = $this->repository('XF:Search');
$search = $searchRepo->runSearch($query, $constraints, false);
if (!$search)
{
return $this->message(\XF::phrase('no_results_found'));
}
$nodeIds = [];
if (!empty($search->search_results))
{
foreach ($search->search_results AS $r)
{
$nodeIds[] = $r[1];
}
}
What I need to do?
On xf_forum db table (entity XF:Forum / not XF:Node), I have a text column, let's call it "title_new".
I need via the same search code, to detect the $nodeIds which are closer to $keywords, by search the xf_forum "title_new" column.
I know that I could made it with a finder->where LIKE %%, but currently I need to use the elastic search and maybe to do the search via the same $query.
As you know xf_forum and xf_node are joined via the node_id column.
Any idea?
If I need to make indexable my "title_new" column, some instructions would be very helpful!