Apache-Solr

 view release on metacpan or  search on metacpan

t/30result.t  view on Meta::CPAN

<responseHeader><status>0</status><QTime>6</QTime></responseHeader>

<result numFound="14" start="0" maxScore="1.0851374">
 <doc>
  <float name="score">1.0851374</float>
  <str name="id">F8V7067-APL-KIT</str>
  <str name="name">Belkin Mobile Power Cord for iPod w/ Dock</str>

 </doc>
 <doc>
  <float name="score">0.68052477</float>
  <str name="id">IW-02</str>
  <str name="name">iPod &amp; iPod Mini USB 2.0 Cable</str>
 </doc>

</result>
</response>
_RESULT2

my $d2 = {
  responseHeader => { status => '0', QTime => '6' },

t/30result.t  view on Meta::CPAN

    maxScore => '1.0851374',
    numFound => '14',
    doc => [
      {
        name => 'Belkin Mobile Power Cord for iPod w/ Dock',
        score => '1.0851374',
        id => 'F8V7067-APL-KIT'
      },
      {
        name => 'iPod & iPod Mini USB 2.0 Cable',
        score => '0.68052477',
        id => 'IW-02'
      }
    ],
    start => '0'
  }
};

#warn "DECODED: ", Dumper decode_xml($f2);
is_deeply(decode_xml($f2), $d2, 'example 2 xml');

### The second document in the result set with debugging info
# http://yourhost.tld:9999/solr/select?q=cat:electronics+Belkin&version=2.1&start=1&rows=1&indent=on&fl=id+name+score&debugQuery=on

my $f3 = <<'_RESULT3';
<?xml version="1.0" encoding="UTF-8"?>
<response>
<responseHeader><status>0</status><QTime>13</QTime></responseHeader>

<result numFound="14" start="1" maxScore="1.0851374">
 <doc>
  <float name="score">0.68052477</float>
  <str name="id">IW-02</str>
  <str name="name">iPod &amp; iPod Mini USB 2.0 Cable</str>

 </doc>
</result>
<lst name="debug">
 <str name="querystring">cat:electronics Belkin</str>
 <str name="parsedquery">cat:electronics text:belkin</str>
 <lst name="explain">
  <str name="id=IW-02,internal_docid=3">
0.6805248 = sum of:
  0.22365452 = weight(cat:electronics in 3), product of:
    0.35784724 = queryWeight(cat:electronics), product of:
      1.0 = idf(docFreq=14)
      0.35784724 = queryNorm
      ...
</str>
 </lst>

</lst>
</response>
_RESULT3

my $d3 = {
  responseHeader => { status => '0', QTime => '13' },
  debug => {
    parsedquery => 'cat:electronics text:belkin',
    querystring => 'cat:electronics Belkin',
    explain => {
      'id=IW-02,internal_docid=3' => '
0.6805248 = sum of:
  0.22365452 = weight(cat:electronics in 3), product of:
    0.35784724 = queryWeight(cat:electronics), product of:
      1.0 = idf(docFreq=14)
      0.35784724 = queryNorm
      ...
'
    }
  },
  result => {
    maxScore => '1.0851374',
    numFound => '14',
    doc => {
      name => 'iPod & iPod Mini USB 2.0 Cable',
      score => '0.68052477',
      id => 'IW-02'
    },
    start => '1'
  }
};

#warn "DECODED: ", Dumper decode_xml($f3);
is_deeply(decode_xml($f3), $d3, 'example 3 xml');

### One document with highlighting



( run in 0.464 second using v1.01-cache-2.11-cpan-7add2cbd662 )