solr java wt javabin_Javabin - SOLR - Apache Software Foundation

javabin is a custom binary format used to write out solr's response in a fast and efficient manner. SOLR-486 is the jira issue .

Currently only a java library is available to write/read this format . This is the default format used by SolrJ and this is the format used for inter-Solr communication in distributed search. Use wt=javabin in request parameter to get the output in this format.

Supported Types

It supports all the data types needed in Solr Response

null

java.lang.String

boolean

byte

short

double

int

long

float

java.util.Map

org.apache.solr.common.SolrDocument

org.apache.solr.common.SolrDocumentList

byte[]

java.util.Iterator

java.util.Date

org.apache.solr.common.util.NamedList

org.apache.solr.common.util.SimpleOrderedMap

Object[] (items must be of any known type)

How to marshal/unmarshal

//example

Map m= new HashMap();

m.put("hello", "world");

OutputStream os = new ByteArrayOutputStream();

new JavaBinCodec().marshal(m,os);

bytes b = ((ByteArrayOutputStream)os).toByteArray()

//now read the Object back

InputStream is =new ByteArrayInputStream(b);

Map m1 = new JavaBinCodec().unmarshal(is);

How do I write any custom types ?

Any custom Object has to be first converted to one of the supported types then marshal it.

Versions

As of Solr 4.0, the JavaBin format introduced a new message that is not recognized by earlier version servers, although the javabin version number has not changed. Also, javabin-formatted update messages were previously routed to /update/javabin, but are now sent to /update, and not properly decoded by older servers configured in the usual way. For this reason, you cannot use a Solr 4.x client to send javabin update requests to Solr 3.x and older servers. The easiest workaround for this problem is to use the XML update format, which is what older servers expect at the /update endpoint, or to hold off updating client software until all servers have been migrated to 4.x

As of Solr 3.1, the JavaBin format has changed to version 2.

Version 2 serializes strings differently: instead of writing the number of UTF-16 characters followed by the bytes in Modified UTF-8 it writes the number of UTF-8 bytes followed by the bytes in UTF-8.

When upgrading from Solr 1.4, if you are using the JavaBin format, you will need to ensure that you also upgrade your SolrJ client.

See the SOLR-2034 jira issue for more information.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值