You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Luis Cappa Banda <lu...@gmail.com> on 2013/05/13 16:52:04 UTC

Quick question about indexing with SolrJ.

Is it possible to index plain String JSON documents using SolrJ? I already
know annotating POJOs works fine, but I need a more flexible way to index
data without any intermediate POJO.

That's because when changing, adding or removing new fields I don't want to
change continously that POJO again and again.


-- 
- Luis Cappa

Re: Quick question about indexing with SolrJ.

Posted by Alexandre Rafalovitch <ar...@gmail.com>.
You can send JSON to Solr as update documents:
http://wiki.apache.org/solr/UpdateJSON. Not sure if SolrJ supports it,
but it is just an HTTP post, so you may not even need SolrJ.

But the issue is that your own JSON probably does not match JSON
expected by Solr. So, you need to map it somehow, right? Unless you
figured that part already.

Regards,
   Alex.
Personal blog: http://blog.outerthoughts.com/
LinkedIn: http://www.linkedin.com/in/alexandrerafalovitch
- Time is the quality of nature that keeps events from happening all
at once. Lately, it doesn't seem to be working.  (Anonymous  - via GTD
book)


On Mon, May 13, 2013 at 11:51 AM, Luis Cappa Banda <lu...@gmail.com> wrote:
> Hello, Jack.
>
> I don't want to use POJOs, that's the main problem. I know that you can
> send AJAX POST HTTP Requests with JSON data to index new documents and I
> would like to do that with SolrJ, that's all, but I don't find the way to
> do that, :-/ . What I would like to do is simple retrieve an String with an
> embedded JSON and add() it via an HttpSolrServer object instance. If the
> JSON matches the Solr server schema.xml or not it would be a server-side
> problem, not a client-side one. I mean, I want to use a best effort and
> more flexible way to index data, and using POJOs is not the way to do that:
> you have to change the Java class, compile it again and relaunch whatever
> the process that uses that Java class.
>
> Regards,
>
> - Luis Cappa
>
>
> 2013/5/13 Jack Krupansky <ja...@basetechnology.com>
>
>> Do your POJOs follow a simple flat data model that is 100% compatible with
>> Solr?
>>
>> If so, maybe you can simply ingest them by setting the Content-type to
>> "application/json" and maybe having to put some minimal wrapper around the
>> raw JSON.
>>
>> But... if they DON'T follow a simple, flat data model, then YOU are going
>> to have to transform their data into a format that does have a simple, flat
>> data model.
>>
>> -- Jack Krupansky
>>
>> -----Original Message----- From: Luis Cappa Banda
>> Sent: Monday, May 13, 2013 10:52 AM
>> To: solr-user@lucene.apache.org
>> Subject: Quick question about indexing with SolrJ.
>>
>>
>> Is it possible to index plain String JSON documents using SolrJ? I already
>> know annotating POJOs works fine, but I need a more flexible way to index
>> data without any intermediate POJO.
>>
>> That's because when changing, adding or removing new fields I don't want to
>> change continously that POJO again and again.
>>
>>
>> --
>> - Luis Cappa
>>
>
>
>
> --
> - Luis Cappa

Re: Quick question about indexing with SolrJ.

Posted by William Bell <bi...@gmail.com>.
Try https://issues.apache.org/jira/browse/SOLR-4685

It allows you to return put JSON from a string field.

Also to convert a XML field to JSON you can use a plugin for DIH

https://issues.apache.org/jira/browse/SOLR-4692

On Monday, May 13, 2013, Chris Hostetter wrote:

>
> : I don't want to use POJOs, that's the main problem. I know that you can
> : send AJAX POST HTTP Requests with JSON data to index new documents and I
> : would like to do that with SolrJ, that's all, but I don't find the way to
> : do that, :-/ . What I would like to do is simple retrieve an String with
> an
> : embedded JSON and add() it via an HttpSolrServer object instance. If the
>
> Use ContentStreamUpdateRequest -- provide your pre-generated JSON as the
> ContentStream (you can back it by a String using
> ContentStreamBase.StringStream or whatever you have to work with) then
> process it against your HttpSolrServer object.
>
>
> -Hoss
>


-- 
Bill Bell
billnbell@gmail.com
cell 720-256-8076

Re: Quick question about indexing with SolrJ.

Posted by Chris Hostetter <ho...@fucit.org>.
: I don't want to use POJOs, that's the main problem. I know that you can
: send AJAX POST HTTP Requests with JSON data to index new documents and I
: would like to do that with SolrJ, that's all, but I don't find the way to
: do that, :-/ . What I would like to do is simple retrieve an String with an
: embedded JSON and add() it via an HttpSolrServer object instance. If the

Use ContentStreamUpdateRequest -- provide your pre-generated JSON as the 
ContentStream (you can back it by a String using 
ContentStreamBase.StringStream or whatever you have to work with) then 
process it against your HttpSolrServer object.


-Hoss

Re: Quick question about indexing with SolrJ.

Posted by Luis Cappa Banda <lu...@gmail.com>.
Hello, Jack.

I don't want to use POJOs, that's the main problem. I know that you can
send AJAX POST HTTP Requests with JSON data to index new documents and I
would like to do that with SolrJ, that's all, but I don't find the way to
do that, :-/ . What I would like to do is simple retrieve an String with an
embedded JSON and add() it via an HttpSolrServer object instance. If the
JSON matches the Solr server schema.xml or not it would be a server-side
problem, not a client-side one. I mean, I want to use a best effort and
more flexible way to index data, and using POJOs is not the way to do that:
you have to change the Java class, compile it again and relaunch whatever
the process that uses that Java class.

Regards,

- Luis Cappa


2013/5/13 Jack Krupansky <ja...@basetechnology.com>

> Do your POJOs follow a simple flat data model that is 100% compatible with
> Solr?
>
> If so, maybe you can simply ingest them by setting the Content-type to
> "application/json" and maybe having to put some minimal wrapper around the
> raw JSON.
>
> But... if they DON'T follow a simple, flat data model, then YOU are going
> to have to transform their data into a format that does have a simple, flat
> data model.
>
> -- Jack Krupansky
>
> -----Original Message----- From: Luis Cappa Banda
> Sent: Monday, May 13, 2013 10:52 AM
> To: solr-user@lucene.apache.org
> Subject: Quick question about indexing with SolrJ.
>
>
> Is it possible to index plain String JSON documents using SolrJ? I already
> know annotating POJOs works fine, but I need a more flexible way to index
> data without any intermediate POJO.
>
> That's because when changing, adding or removing new fields I don't want to
> change continously that POJO again and again.
>
>
> --
> - Luis Cappa
>



-- 
- Luis Cappa

Re: Quick question about indexing with SolrJ.

Posted by Jack Krupansky <ja...@basetechnology.com>.
Do your POJOs follow a simple flat data model that is 100% compatible with 
Solr?

If so, maybe you can simply ingest them by setting the Content-type to 
"application/json" and maybe having to put some minimal wrapper around the 
raw JSON.

But... if they DON'T follow a simple, flat data model, then YOU are going to 
have to transform their data into a format that does have a simple, flat 
data model.

-- Jack Krupansky

-----Original Message----- 
From: Luis Cappa Banda
Sent: Monday, May 13, 2013 10:52 AM
To: solr-user@lucene.apache.org
Subject: Quick question about indexing with SolrJ.

Is it possible to index plain String JSON documents using SolrJ? I already
know annotating POJOs works fine, but I need a more flexible way to index
data without any intermediate POJO.

That's because when changing, adding or removing new fields I don't want to
change continously that POJO again and again.


-- 
- Luis Cappa