繁体   English   中英

我如何处理日光浴室上的关系? 就像我们可以通过使用select和where在SQL上执行的操作

[英]how i can do the relation on solarium? like what we can do on SQL by using select and where

这是我的代码。 我想在他的书中显示作者的名字。 我已经将两个文件上传到Solr(书,作者),并且两个文件之间存在列共享(另一个文件上的authid和书文件上的oAuth)。 我不知道如何在Solarium中执行此过程?

<?php

require(__DIR__.'/init.php');
htmlHeader();

// create a client instance
$client = new Solarium\Client($config);

// get a select query instance
$query = $client->createSelect();
//be sure to validate and clean your variables
$val1 = htmlentities($_GET['searchSolr']);
//then you can use them in a PHP function. 

$query->createFilterQuery('search')->setQuery(('bk:'). $val1);

// this executes the query and returns the result
$resultset = $client->select($query);

// display the total number of documents found by solr
echo 'عدد نتائج البحث: '.$resultset->getNumFound();

// show documents using the resultset iterator
foreach ($resultset as $document) {

    echo '<hr/><table>';
    echo '<tr><th>اسم الكتاب:</th><td>' . $document->bk[0] . '</td></tr>';
    echo '<tr><th>رقم الكتاب:</th><td>' . $document->bkid[0] . '</td></tr>';
    echo '</table>';
}

htmlFooter();

Solr无法执行常规联接,常规联接唯一受支持的功能是使用联接的一侧来过滤另一侧-即与INNER JOIN相同。 在您的情况下,您需要双方的信息(作者姓名和书名),而Solr中的“加入”功能是无法实现的。

如果您以其云模式运行Solr,可以使用流表达式来解决,但是解决此问题的首选方法是将作者的姓名添加到书籍文档本身。 这样,它便是一本书所需数据的一部分(而且作者的名字通常不会经常更改,因此执行更新非常容易管理)。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM