GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
Apache::Solr::Document(3) User Contributed Perl Documentation Apache::Solr::Document(3)

Apache::Solr::Document - Apache Solr (Lucene) Document container

  # create and upload a new document
  my $doc = Apache::Solr::Document->new(...);
  $doc->addField(id => 'tic');
  $doc->addFields( {name => 'tac', foot => 'toe'}, boost => 2);

  $solr->addDocument($doc, commit => 1, overwrite => 1)

  # take results
  my $results = $solr->select
    ( q  => 'text:gold'             # search text-fields for 'gold'
    , hl => { field => 'content' }  # highlight 'gold' in content'
    );

  my $doc = $results->selected(3);  # fourth answer
  print $doc->rank;                 # 3

  print $doc->uniqueId;             # usually the 'id' field

  @names = $doc->fieldNames;
  print $doc->field('subject')->{content};
  print $doc->content('subject');   # same
  print $doc->_subject;             # same, via autoload (mind the '_'!)

  my $hl  = $results->highlighted($doc);  # another ::Doc object
  print $hl->_content;              # highlighted field named 'content'

This object wraps-up an document: a set of fields. Either, this is a document which has to be added to the Solr database using Apache::Solr::addDocument(), or the subset of a document as returned by Apache::Solr::select().

Apache::Solr::Document->fromResult(HASH, $rank)
Create a document object from data received as result of a select search.
Apache::Solr::Document->new(%options)
 -Option--Default
  boost   1.0
  fields  {}
    
boost => FLOAT
Boost the preference for hits in this document.
fields => HASH|ARRAY
Passed to addFields().

$obj->addField($name, $content, %options)
$content can be specified as SCALAR (reference) for performance. In that case, a reference to the original will be kept. When "undef", the field gets ignored.

 -Option--Default
  boost   1.0
  update  undef
    
boost => FLOAT
update => 'add'|'set'|'inc'|...
[1.02, Solr 4.0] See 'Atomic Updates' in https://cwiki.apache.org/confluence/display/solr/Updating+Parts+of+Documents
$obj->addFields(HASH|ARRAY, %options)
The HASH or ARRAY containing NAME/CONTENT pairs. The %options are passed addField() as %options.
$obj->boost( [$fieldname, [$boost]] )
Boost value for all fields in the document.

[0.93] When a FIELD NAME is given, the boost specific for that field is returned (not looking at the document's boost value) This can also be used to set the $boost value for the field.

$obj->content($name)
Returns the content of the first field with $name.
$obj->field($name)
Returns the first field with $name (or undef). This is a HASH, containing "name", "content" and sometimes a "boost" key.

If you need the content (that's the usually the case), you can also (probably more readible) use the (autoloaded) method NAMEd after the field with a leading '_'.

example:

   $doc->field('subject')->{content};
   $doc->content('subject');
   $doc->_subject;
    
$obj->fieldNames()
All used unique names.
$obj->fields( [$name] )
Returns a list of HASHs, each containing at least a "name" and a "content". Each HASH will also contain a "boost" value. When a $name is provided, only those fields are returned.
$obj->rank()
Only defined when the document contains results of a search: the ranking. A value of '0' means "best".
$obj->uniqueId()
Returns the value of the unique key associated with the document "id". Only the server knowns which field is the unique one. If it differs from the usual "id", you have to set it via global value $Apache::Solr::uniqueKey

This module is part of Apache-Solr distribution version 1.05, built on January 11, 2019. Website: http://perl.overmeer.net/CPAN/

Copyrights 2012-2019 by [Mark Overmeer]. For other contributors see ChangeLog.

This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. See http://dev.perl.org/licenses/

2019-01-11 perl v5.32.1

Search for    or go to Top of page |  Section 3 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.