Update specific field on SOLR index

Viewed 23335

I want to using solr for search on articles

I have 3 table:

  1. Group (id , group name)
  2. ArticleBase (id, groupId, some other field)
  3. Article(id, articleBaseId, title, date, ...)

in solr schema.xml file i just define all article field that mixed with ArticleBase table (for use one index on solr) like this: (id, articleBaseId, groupId, ...)

problem: Admin want to change group (ArticleBase), therefore i must update (or replace) all indexed article in solr. right ?
can i update groupId only in solr index ?

have any solution ?

Note:Article table contains more than 200 million article, and i using solr for index only (not store any field data except article id)

6 Answers

You can refer to this documentation for Partial Updates. You can make an update either by replacing it or adding more values to that particular field although (like a list), it's not required in your case

Solr supports different types of Update Operations.

The set of update operations supported by Solr.

'add' - add a new value or values to an existing Solr document field, or add a new field and value(s).

'set' - change the value or values in an existing Solr document field.

'remove' - remove all occurrences of the value or values from an existing Solr document field.

Here is an example of how to do a partial update via Solr’s Java client, SolrJ

// create the SolrJ client
HttpSolrClient solrClient = new HttpSolrClient("http://localhost:8983/solr");
// for clould there is CloudSolrClient api

// create the document
SolrInputDocument solrDocument = new SolrInputDocument();
solrDocument.addField("id","12345");
Map<String,Object> solrUpdates = new HashMap<>(1);
solrUpdates.put("address","Pune");
solrDocument.addField("cat", solrUpdates); 

solrClient.add( solrDocument );  
solrClient.close();  
Related