Set solr field values based on other fields

46 Views Asked by At

I have three fields in the Solr core:

  • Field1,
  • Field2,
  • Field3.

I am setting a value for Field1 and Field2 in the DIH, but I want to set the value for Field3 based on some values in Field1 and Field2.

For Example, Field1 and Field2 are the boolean types so I want to check if either Field1 or Field2 is true and then set the Field3 value as true otherwise set false.

1

There are 1 best solutions below

0
Kyrylo Romantsov On

The easiest way to achieve it is to use a script in your DIH, here is an example:

<document>
  <entity ...>
    <field column="..." name="Field1" />
    <field column="..." name="Field2" />
    
    <field name="Field3" script="Field1 || Field2" />
  </entity>
</document>