How to add a new field to the document in a custom Solr Filter


I am writing a custom filter in Solr to post a token to Apache Stanbol for enhancement and index the response to a different field in the same document.

In my test code below I have got the Stanbol response and have added it as a new document to Solr. My requirement is to add the stanbolResponse as a field value to the same document being indexed. I think this can be done if I can retrieve the document Id from the TokenStream in the filter.

Can anyone please help me with a sample code/example or a link on how to achieve this?

<pre class="lang-java prettyprint-override">public boolean incrementToken() throws IOException { if (!input.incrementToken()) { return false; } int length = charTermAttr.length(); char[] buffer = charTermAttr.buffer(); String content = new String(buffer); Client client = Client.create(); WebResource webResource = client.resource(stanbol_endpoint + "enhancer"); ClientResponse response = webResource .type(MediaType.TEXT_PLAIN) .accept(new MediaType("application", "rdf+xml")) .entity(content2,MediaType.TEXT_PLAIN) .post(ClientResponse.class); int status = response.getStatus(); if (status != 200 && status != 201 && status != 202) { throw new RuntimeException("Failed : HTTP error code : " + response.getStatus()); } String output = response.getEntity(String.class); charTermAttr.setEmpty(); char[] newBuffer = output.toCharArray(); charTermAttr.copyBuffer(newBuffer, 0, newBuffer.length); SolrInputDocument doc1 = new SolrInputDocument(); doc1.addField( "id", "id1", 1.0f ); doc1.addField("stanbolResponse", output); try { server.add(doc1); server.commit(); } catch (SolrServerException e) { System.out.println("error while indexing response to solr"); e.printStackTrace(); } return true; }


This usecase was successfuly covered by writing a custom UpdateRequestProcessor and configuring the /update request handler to use my custom processor in the update.chain.

I was able to process and add new fields to the document prior to indexing. Below is how I configured my /update request handler with my custom processor.

RequestProcessor for stanbol process:

<updateRequestProcessorChain name="stanbolInterceptor"> <processor class="com.solr.stanbol.processor.StanbolContentProcessorFactory"/> <processor class="solr.RunUpdateProcessorFactory" /> </updateRequestProcessorChain>

configure the request-handler with above chain for update.chain:

<requestHandler name="/update" class="solr.UpdateRequestHandler"> <lst name="defaults"> <str name="update.chain">stanbolInterceptor</str> </lst> </requestHandler>


  • C++ String tokenisation from 3D .obj files
  • Determining the length of a read stream in node js
  • Runtime error in UVA Online Judge [closed]
  • 3.0.0.M1: SSL - Invalid keystore format
  • incomplete type 'struct' error in C
  • What is the difference between a “service account” and an “installed application”?
  • Problem with Django using Apache2 (mod_wsgi), Occassionally is “unable to import from module” for no
  • Python pandas melting data to multiple columns and coulmn names in another column
  • How to copy styled text in JTextPane
  • what makes a request a new request in asp.net C#
  • Spring Cloud Microservice Architecture Confusion
  • Using a canvas object in a thread to do simple animations - Java
  • Transactional Create with Validation in ServiceStack Redis Client
  • How to test if a URL from an Eclipse bundle is a directory?
  • Handling un-mapped Rest path
  • Java Scanner input dilemma. Automatically inputs without allowing user to type
  • PHP - How to update data to MySQL when click a radio button
  • DotNetZip - Calculate final zip size before calling Save(stream)
  • AES padding and writing the ciphertext to a disk file
  • Convert array of 8 bytes to signed long in C++
  • what is the difference between the asp.net mvc application and asp.net web application
  • Warning: Can't call setState (or forceUpdate) on an unmounted component
  • AT Commands to Send SMS not working in Windows 8.1
  • Comma separated Values
  • Matrix multiplication with MKL
  • Linker errors when using intrinsic function via function pointer
  • Windows forms listbox.selecteditem displaying “System.Data.DataRowView” instead of actual value
  • Load html files in TinyMce
  • Error creating VM instance in Google Compute Engine
  • Free memory of cv::Mat loaded using FileStorage API
  • Hits per day in Google Big Query
  • how does django model after text[] in postgresql [duplicate]
  • LevelDB C iterator
  • apache spark aggregate function using min value
  • Django query for large number of relationships
  • Sorting a 2D array using the second column C++
  • Why is Django giving me: 'first_name' is an invalid keyword argument for this function?
  • Binding checkboxes to object values in AngularJs
  • How can I use `wmic` in a Windows PE script?
  • How to push additional view controllers onto NavigationController but keep the TabBar?