lucene-solr-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Erick Erickson <erickerick...@gmail.com>
Subject Re: [RESOLVED] Re: Need help on this AND query, solr returning incorrect results?
Date Wed, 15 Oct 2014 05:19:33 GMT
Glad it worked. That's one of Solr's little quirks that _everybody_ finds out,
usually painfully.....

Erick

On Tue, Oct 14, 2014 at 10:04 PM, Aaron Lewis
<the.warl0ck.1989@gmail.com> wrote:
> Thanks Erick, the uppercase worked, I just didn't know that ...
>
> On Wed, Oct 15, 2014 at 1:00 PM, Erick Erickson <erickerickson@gmail.com> wrote:
>> and is case sensitive, have you tried it with AND?
>>
>> So this query is probably parsed as
>>
>> title:facebook OR defaultsearchfield:and OR subject:java
>>
>> assuming your default operator is "OR"....
>>
>> Try it on the URL with &debug=query for a quick check of what the actual
>> query is after it's made it through all the parsing...
>>
>> Best,
>> Erick
>>
>> On Tue, Oct 14, 2014 at 7:46 PM, Aaron Lewis <the.warl0ck.1989@gmail.com> wrote:
>>> 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
>
>
>
> --
> 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