Apache-Solr

 view release on metacpan or  search on metacpan

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

 <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
# http://localhost:8983/solr/select/?stylesheet=&q=solr+xml&version=2.1&start=0&rows=10&indent=on&hl=true&hl.fl=features,sku&hl.snippets=3

my $f4 = <<'_RESULT4';
<?xml version="1.0" encoding="UTF-8"?>
<response>
<responseHeader><status>0</status><QTime>3</QTime></responseHeader>

<result numFound="1" start="0">
 <doc>
  <arr name="cat"><str>software</str><str>search</str></arr>
  <arr name="features"><str>Advanced Full-Text Search Capabilities using Lucene</str><str>Optimizied for High Volume Web Traffic</str><str>Standards Based Open Interfaces - XML and HTTP</str>

        <str>Comprehensive HTML Administration Interfaces</str><str>Scalability - Efficient Replication to other Solr Search Servers</str><str>Flexible and Adaptable with XML configuration and Schema</str><str>Good unicode support: héllo (hello with...
  <str name="id">SOLR1000</str>
  <bool name="inStock">true</bool>
  <str name="manu">Apache Software Foundation</str>
  <str name="name">Solr, the Enterprise Search Server</str>

  <int name="popularity">10</int>
  <float name="price">0.0</float>
  <str name="sku">SOLR1000</str>
 </doc>
</result>
<lst name="highlighting">
 <lst name="SOLR1000">
  <arr name="features">

        <str>Standards Based Open Interfaces - &lt;em>XML&lt;/em> and HTTP</str>
        <str>Scalability - Efficient Replication to other &lt;em>Solr&lt;/em> Search Servers</str>
        <str>Flexible and Adaptable with &lt;em>XML&lt;/em> configuration and Schema</str>
  </arr>

  <arr name="sku">
        <str>&lt;em>SOLR&lt;/em>1000</str>
  </arr>
 </lst>
</lst>
</response>
_RESULT4

my $d4 = {
  responseHeader => { status => '0', QTime => '3' },
  result => {
    numFound => '1',
    doc => {
      sku => 'SOLR1000',
      features => [
        'Advanced Full-Text Search Capabilities using Lucene',
        'Optimizied for High Volume Web Traffic',
        'Standards Based Open Interfaces - XML and HTTP',
        'Comprehensive HTML Administration Interfaces',
        'Scalability - Efficient Replication to other Solr Search Servers',
        'Flexible and Adaptable with XML configuration and Schema',
        "Good unicode support: h\x{e9}llo (hello with an accent over the e)"
      ],
      name => 'Solr, the Enterprise Search Server',
      manu => 'Apache Software Foundation',
      cat => [ 'software', 'search' ],
      popularity => '10',
      price => '0.0',
      id => 'SOLR1000',
      inStock => 1
    },
    start => '0'
  },
  highlighting => {
    SOLR1000 => {
      sku => [ '<em>SOLR</em>1000' ],
      features => [
        'Standards Based Open Interfaces - <em>XML</em> and HTTP',
        'Scalability - Efficient Replication to other <em>Solr</em> Search Servers',
        'Flexible and Adaptable with <em>XML</em> configuration and Schema'
      ]
    }
  },
};

#warn "DECODED: ", Dumper decode_xml($f4);
is_deeply(decode_xml($f4), $d4, 'example 4 xml');



( run in 1.486 second using v1.01-cache-2.11-cpan-5837b0d9d2c )