NAME

Apache::Solr::JSON - Apache Solr (Lucene) client via JSON

INHERITANCE

Apache::Solr::JSON
  is an Apache::Solr

SYNOPSIS

my $solr = Apache::Solr::JSON->new(...);
my $solr = Apache::Solr->new(format => 'JSON', ...);

DESCRIPTION

Implement the Solr client, where the communication is in JSON.

Both the requests and the responses are using JSON syntax, produced by the JSON distribution (which defaults to JSON::XS when installed)

Warning 1: Apparently, Perl's JSON implementation does not support the repetition of keys in one list, but Solr is using that. Care is taken to avoid these cases.

Warning 2: In some cases, XML and JSON differ in structure and names in the structure. In those cases, the XML plan is made leading: the JSON data is transformed to match the XML.

Extends "DESCRIPTION" in Apache::Solr.

METHODS

Extends "METHODS" in Apache::Solr.

Constructors

Extends "Constructors" in Apache::Solr.

$class->new(%options)

Inherited, see "Constructors" in Apache::Solr

-Option            --Defined in     --Default
 agent               Apache::Solr     <created internally>
 autocommit          Apache::Solr     true
 core                Apache::Solr     undef
 field_key_simplify  Apache::Solr     true
 format              Apache::Solr     'JSON'
 json                                 <created internally>
 retry_max           Apache::Solr     60
 retry_wait          Apache::Solr     5
 server              Apache::Solr     <required>
 server_version      Apache::Solr     <latest>
agent => LWP::UserAgent-object
autocommit => BOOLEAN
core => $name
field_key_simplify => BOOLEAN
format => 'XML'|'JSON'
json => JSON object

By default, an JSON object is created for you, in utf8 mode.

retry_max => COUNT
retry_wait => $seconds
server => $url
server_version => $version

Attributes

Extends "Attributes" in Apache::Solr.

$obj->agent()

Inherited, see "Attributes" in Apache::Solr

$obj->autocommit( [BOOLEAN] )

Inherited, see "Attributes" in Apache::Solr

$obj->core( [$core] )

Inherited, see "Attributes" in Apache::Solr

$obj->fieldKeySimplify()

Inherited, see "Attributes" in Apache::Solr

$obj->json()

$obj->server( [$uri|STRING] )

Inherited, see "Attributes" in Apache::Solr

$obj->serverVersion()

Inherited, see "Attributes" in Apache::Solr

Commands

See https://wiki.apache.org/solr/UpdateJSON

Extends "Commands" in Apache::Solr.

Extends "Search" in Apache::Solr.

$obj->queryTerms($terms)

Inherited, see "Search" in Apache::Solr

$obj->select( [\%options], @parameters )

Inherited, see "Search" in Apache::Solr

Updates

Extends "Updates" in Apache::Solr.

$obj->addDocument($doc|\@docs, %options)

Inherited, see "Updates" in Apache::Solr

-Option            --Defined in     --Default
 allowDups           Apache::Solr     false
 commit              Apache::Solr     <autocommit>
 commitWithin        Apache::Solr     undef
 overwrite           Apache::Solr     true
 overwriteCommitted  Apache::Solr     <not allowDups>
 overwritePending    Apache::Solr     <not allowDups>
allowDups => BOOLEAN
commit => BOOLEAN
commitWithin => $seconds
overwrite => BOOLEAN
overwriteCommitted => BOOLEAN
overwritePending => BOOLEAN
$obj->commit(%options)

Inherited, see "Updates" in Apache::Solr

$obj->delete(%options)

Inherited, see "Updates" in Apache::Solr

$obj->extractDocument(%options)

Inherited, see "Updates" in Apache::Solr

$obj->optimize(%options)

Inherited, see "Updates" in Apache::Solr

$obj->rollback()

Inherited, see "Updates" in Apache::Solr

Core management

Extends "Core management" in Apache::Solr.

$obj->coreReload(%options)

Inherited, see "Core management" in Apache::Solr

$obj->coreStatus(%options)

Inherited, see "Core management" in Apache::Solr

$obj->coreUnload(%options)

Inherited, see "Core management" in Apache::Solr

Helpers

Extends "Helpers" in Apache::Solr.

$obj->decodeResponse($response)

$obj->simpleDocument( $command, [$attributes, [$content]] )

Construct a simple XML structure.

$obj->simpleUpdate( $command, $attributes, [$content] )

DETAILS

Extends "DETAILS" in Apache::Solr.

DIAGNOSTICS

Fault: Cannot read document from $fn: $!

Cast by extractDocument()

Fault: Read error for document $fn: $!

Cast by extractDocument()

Fault: Solr request failed after $elapse seconds after $retries retries: $!

Cast by request()

Alert: Solr request failed with $code, $retries retries left: $!

Cast by request()

Error: Solr request failed with: $err

Cast by request()

Error: Solr version too old for updates in JSON syntax.

Cast by addDocument()

Error: Solr version too old for updates in JSON syntax.

Cast by simpleUpdate()

Error: answer from solr server is not json but $type.

Cast by decodeResponse()

Warning: deprecated solr $message

Cast by deprecated()

Error: extract requires document as file or string.

Cast by extractDocument()

Error: extractDocument() requires Solr v1.4 or higher.

Cast by extractDocument()

Error: field $field is not simple for a set.

Cast by expandSelect()

Warning: ignored solr $message

Cast by ignored()

Warning: removed solr $message

Cast by removed()

Error: rollback not supported by your solr server version.

Cast by rollback()

Error: set $set cannot be used per field, in $field.

Cast by expandSelect()

Error: unable to add more than one doc with JSON interface.

Cast by addDocument()

Error: unknown field set $set.

Cast by expandSelect()

SEE ALSO

This module is part of Apache-Solr version 1.12, built on July 15, 2026. Website: https://perl.overmeer.net/CPAN/

LICENSE

For contributors see file ChangeLog.

This software is copyright (c) 2012-2026 by Mark Overmeer.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.