You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by P Williams <wi...@gmail.com> on 2013/09/18 21:19:31 UTC
DIH field defaults or re-assigning field values
Hi All,
I'm using the DataImportHandler to import documents to my index. I assign
one of my document's fields by using a sub-entity from the root to look for
a value in a file. I've got this part working. If the value isn't in the
file or the file doesn't exist I'd like the field to be assigned a default
value. Is there a way to do this?
I think I'm looking for a way to re-assign the value of a field. If this
is possible then I can assign the default value in the root entity and
overwrite it if the value is found in the sub-entity. Ideas?
Thanks,
Tricia
Re: DIH field defaults or re-assigning field values
Posted by P Williams <wi...@gmail.com>.
I discovered how to use the
ScriptTransformer<http://wiki.apache.org/solr/DataImportHandler#ScriptTransformer>
which
worked to solve my problem. I had to make use
of context.setSessionAttribute(...,...,'global') to store a flag for the
value in the file because the script is only called if there are rows to
transform and I needed to know when the default was appropriate to set in
the root entity.
Thanks for your suggestions Alex.
Cheers,
Tricia
On Wed, Sep 18, 2013 at 1:19 PM, P Williams
<wi...@gmail.com>wrote:
> Hi All,
>
> I'm using the DataImportHandler to import documents to my index. I assign
> one of my document's fields by using a sub-entity from the root to look for
> a value in a file. I've got this part working. If the value isn't in the
> file or the file doesn't exist I'd like the field to be assigned a default
> value. Is there a way to do this?
>
> I think I'm looking for a way to re-assign the value of a field. If this
> is possible then I can assign the default value in the root entity and
> overwrite it if the value is found in the sub-entity. Ideas?
>
> Thanks,
> Tricia
>
Re: DIH field defaults or re-assigning field values
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
You could also do this in request update processor. There is a default
value one there. Also, I think field definition in schema allows defaults.
Regards,
Alex
On 19 Sep 2013 02:20, "P Williams" <wi...@gmail.com> wrote:
> Hi All,
>
> I'm using the DataImportHandler to import documents to my index. I assign
> one of my document's fields by using a sub-entity from the root to look for
> a value in a file. I've got this part working. If the value isn't in the
> file or the file doesn't exist I'd like the field to be assigned a default
> value. Is there a way to do this?
>
> I think I'm looking for a way to re-assign the value of a field. If this
> is possible then I can assign the default value in the root entity and
> overwrite it if the value is found in the sub-entity. Ideas?
>
> Thanks,
> Tricia
>