Updating a single field using Solrj ContentStreamUpdateRequest

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Updating a single field using Solrj ContentStreamUpdateRequest

Joris De Smedt
Hi

I'd like to update a single field of an existing document with the content
of a file.
My current setup looks like this:

   final File file = new File("path to file");
   ContentStreamUpdateRequest req = new
ContentStreamUpdateRequest("/update/extract");
   req.addContentStream(new ContentStreamBase.FileStream(file));
   req.setParam("literal.id", id);
   req.setParam("uprefix","ignored_");
   req.setParam("fmap.content", "content");
   req.setParam("captureAttr","true");
   req.setParam("lowernames","true");
   solrClient.request(req, "collection");
   solrClient.commit("collection");

The problem with it is that it overwrites the existing file instead of
adding a content field.
Is there a way to solve this?
--
Joris De Smedt
Reply | Threaded
Open this post in threaded view
|

Re: Updating a single field using Solrj ContentStreamUpdateRequest

Emir Arnautović
Hi Joris,
I doubt that you can do that. That would require extracting request handler to support incremental updating and I don’t thing it does. In order to update existing doc, you would have to extract content and send it as incrementa update request.
You can still use extracting handler to extract content by sending extractOnly=true and get extraction results in response, but maybe better to invoke Tika on client side.

HTH,
Emir
--
Monitoring - Log Management - Alerting - Anomaly Detection
Solr & Elasticsearch Consulting Support Training - http://sematext.com/



> On 1 Feb 2018, at 11:54, Joris De Smedt <[hidden email]> wrote:
>
> Hi
>
> I'd like to update a single field of an existing document with the content
> of a file.
> My current setup looks like this:
>
>   final File file = new File("path to file");
>   ContentStreamUpdateRequest req = new
> ContentStreamUpdateRequest("/update/extract");
>   req.addContentStream(new ContentStreamBase.FileStream(file));
>   req.setParam("literal.id", id);
>   req.setParam("uprefix","ignored_");
>   req.setParam("fmap.content", "content");
>   req.setParam("captureAttr","true");
>   req.setParam("lowernames","true");
>   solrClient.request(req, "collection");
>   solrClient.commit("collection");
>
> The problem with it is that it overwrites the existing file instead of
> adding a content field.
> Is there a way to solve this?
> --
> Joris De Smedt

Reply | Threaded
Open this post in threaded view
|

Re: Updating a single field using Solrj ContentStreamUpdateRequest

Joris De Smedt
Thanks I think we'll go for extractOnly cause using a recent version of
Tika causes to many dependency issues.

On Thu, Feb 1, 2018 at 12:25 PM, Emir Arnautović <
[hidden email]> wrote:

> Hi Joris,
> I doubt that you can do that. That would require extracting request
> handler to support incremental updating and I don’t thing it does. In order
> to update existing doc, you would have to extract content and send it as
> incrementa update request.
> You can still use extracting handler to extract content by sending
> extractOnly=true and get extraction results in response, but maybe better
> to invoke Tika on client side.
>
> HTH,
> Emir
> --
> Monitoring - Log Management - Alerting - Anomaly Detection
> Solr & Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
> > On 1 Feb 2018, at 11:54, Joris De Smedt <[hidden email]>
> wrote:
> >
> > Hi
> >
> > I'd like to update a single field of an existing document with the
> content
> > of a file.
> > My current setup looks like this:
> >
> >   final File file = new File("path to file");
> >   ContentStreamUpdateRequest req = new
> > ContentStreamUpdateRequest("/update/extract");
> >   req.addContentStream(new ContentStreamBase.FileStream(file));
> >   req.setParam("literal.id", id);
> >   req.setParam("uprefix","ignored_");
> >   req.setParam("fmap.content", "content");
> >   req.setParam("captureAttr","true");
> >   req.setParam("lowernames","true");
> >   solrClient.request(req, "collection");
> >   solrClient.commit("collection");
> >
> > The problem with it is that it overwrites the existing file instead of
> > adding a content field.
> > Is there a way to solve this?
> > --
> > Joris De Smedt
>
>


--
Joris De Smedt