lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Aaron Lewis <the.warl0ck.1...@gmail.com>
Subject Need help on this AND query, solr returning incorrect results?
Date Wed, 15 Oct 2014 02:46:32 GMT
Hi,

I've indexed two rows with two columns:

title: Google
subject: Java Interface

and another

title: FaceBook
subject: Not Java

Now I use this query:

title:"facebook" and subject:"java"

It returns both of the rows above, weird. It looks like an "OR" query
to me, hmm.

Attached the original PHP code (replace the `if (0)` if you're
inserting data for the first time)
------------------------------------------------------------------------------------------------------------------------------------------------

<?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);

?>



-- 
Best Regards,
Aaron Lewis - PGP: 0x13714D33 - http://pgp.mit.edu/
Finger Print:   9F67 391B B770 8FF6 99DC  D92D 87F6 2602 1371 4D33

Mime
View raw message