简体   繁体   English

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

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

This is my code. 这是我的代码。 I want to display the author name with his book. 我想在他的书中显示作者的名字。 I had uploaded two files to Solr (book, author) and there is column share between the two file ( authid on another file and oAuth on book file). 我已经将两个文件上传到Solr(书,作者),并且两个文件之间存在列共享(另一个文件上的authid和书文件上的oAuth)。 I don't know how can do this process in Solarium? 我不知道如何在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 can't perform regular joins, the only supported functionality for regular joins is to use one side of the join to filter the other side - ie the same as an INNER JOIN. Solr无法执行常规联接,常规联接唯一受支持的功能是使用联接的一侧来过滤另一侧-即与INNER JOIN相同。 In your case you want information from both sides (the author name and the book title), which just isn't possible with the "join" functionality in Solr. 在您的情况下,您需要双方的信息(作者姓名和书名),而Solr中的“加入”功能是无法实现的。

If you're running Solr in its cloud mode, using a streaming expression can be a solution, but the preferred way to solve this is to just add the name of the author to the book document itself. 如果您以其云模式运行Solr,可以使用流表达式来解决,但是解决此问题的首选方法是将作者的姓名添加到书籍文档本身。 That way it's part of the data you need for a book (and an author's name usually doesn't change often, so performing updates will be very manageable). 这样,它便是一本书所需数据的一部分(而且作者的名字通常不会经常更改,因此执行更新非常容易管理)。

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

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