I have two fields in a solr document, "title" and "subject" (both are available by default)
Then I place two rows in the database, and search on them.
But the AND query title:"facebook" and subject:"java"
returns both the rows.
It should only return the second row, right?
<?php
$solr = new SolrClient (array ('hostname' => '127.0.0.1'));
/////// INSERT ////////
if (0)
{
$data = array (
array (
'id' => 100,
'title' => 'Google',
'subject' => 'Java Interface'
),
array (
'id' => 101,
'title' => 'FaceBook',
'subject' => 'Not Java'
)
);
foreach ($data as $input)
{
$doc = new SolrInputDocument();
foreach ($input as $key => $value)
{
$doc->addField ($key, $value);
}
$solr->addDocument ($doc, false, 1000);
}
sleep (3);
}
/////// QUERY ////////
$query = new SolrQuery();
$query->setQuery('title:"facebook" and subject:"java"');
$query->addField('id')->addField('title')->addField('subject');
$resp = $solr->query($query)->getResponse ();
print_r ($resp->response->docs);
?>