Thank you Alexandre! It worked great. :)

And here is how it is configured, if someone else wants to do this, but is too 
busy to read the documentation for these classes:

<updateRequestProcessorChain name="defaultUpdateRequestProcessorChain" 
default="true">
        <processor class="solr.CloneFieldUpdateProcessorFactory">
                <str name="source">source_field</str>
                <str name="dest">target_field</str>
        </processor>
        <processor class="solr.FirstFieldValueUpdateProcessorFactory">
                <str name="fieldName"> target_field </str>
        </processor>
        [...]
</updateRequestProcessorChain>

/Jimi

-----Original Message-----
From: Alexandre Rafalovitch [mailto:arafa...@gmail.com] 
Sent: Tuesday, October 3, 2017 7:02 PM
To: solr-user <solr-user@lucene.apache.org>
Subject: Re: Default value from another field?

I believe you should be able to use a combination of:
http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/update/processor/CloneFieldUpdateProcessorFactory.html
and
http://www.solr-start.com/javadoc/solr-lucene/org/apache/solr/update/processor/FirstFieldValueUpdateProcessorFactory.html

So, if you have no value in target field, you end up with one (copied one). And 
if you did, you end up with one (original one).

This is available in the stock Solr, just need to configure it.

Regards,
   Alex.
----
http://www.solr-start.com/ - Resources for Solr users, new and experienced


On 3 October 2017 at 12:14,  <jimi.hulleg...@svensktnaringsliv.se> wrote:
> Hi Emir,
>
> Thanks for the tip about DefaultValueUpdateProcessorFactory. But even though 
> I agree that it most likely isn't too hard to write custom code that does 
> this, the overhead is a bit too much I think considering we now use a vanilla 
> Solr with no custom code deployed. So we would need to setup a new project, 
> and a new deployment procedure, and that is a bit overkill considering that 
> this is a feature that would help me as a developer and administrator only a 
> little bit (ie nice-to-have), and at the same time would not have any impact 
> for any end user (except, possibly negative side effects because of bugs etc).
>
> Regards
> /Jimi
>
>
> -----Original Message-----
> From: Emir Arnautović [mailto:emir.arnauto...@sematext.com]
> Sent: Tuesday, October 3, 2017 3:28 PM
> To: solr-user@lucene.apache.org
> Subject: Re: Default value from another field?
>
> Hi Jimi,
> I don’t think that you can do it using schema, but you could do it 
> using custom update request processor chain. I quickly scanned to see 
> if there is such processor and could not find one. The closest one is 
> https://lucene.apache.org/solr/6_6_0//solr-core/org/apache/solr/update
> /processor/DefaultValueUpdateProcessorFactory.html 
> <https://lucene.apache.org/solr/6_6_0//solr-core/org/apache/solr/updat
> e/processor/DefaultValueUpdateProcessorFactory.html>
> It should not be too hard to adjust it to do what you need.
>
> HTH,
> Emir
>
> --
> Monitoring - Log Management - Alerting - Anomaly Detection Solr & 
> Elasticsearch Consulting Support Training - http://sematext.com/
>
>
>
>> On 3 Oct 2017, at 14:10, jimi.hulleg...@svensktnaringsliv.se wrote:
>>
>> Hi,
>>
>> Is it possible using some Solr schema magic to make solr get the default 
>> value for a field from another field? Ie, if the value is specified in the 
>> document to be indexed, then that value is used. Otherwise it uses the value 
>> of another field. As far as I understand it, the field property "default" 
>> only takes a static value, not a reference to another field. And the 
>> copyField element doesn't solve this problem either, since it will result in 
>> two values if the field was specified in the document, and I only want a 
>> single value.
>>
>> /Jimi
>

Reply via email to