簡體   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