4

I tried to use copyField like a chain but it doesn't seems to work. Here my example:

<copyField source="allfields" dest="metafields1" />
<copyField source="metafields1" dest="metafields2" />
<copyField source="metafields2" dest="metafields3" />

Each field uses a different fieldType.

The problem is that except of allfields and metafields1 the other have no content after indexing. Is solr unable to copy from another copyField? I use solr 3.5.

Mewel
  • 1,279
  • 15
  • 21

2 Answers2

11

Documentation @ http://wiki.apache.org/solr/SchemaXml#Copy_Fields

The copy is done at the stream source level and no copy feeds into another copy.

Having a copyfield as the source of copyfield tag does not work.
The copyfield source must be an actual field, which has some value and does no cascade.

You can also check http://lucene.472066.n3.nabble.com/does-copyField-recurse-td2450208.html

Jayendra
  • 52,349
  • 4
  • 80
  • 90
0

As Jayendra said the copy is done @ stream source level while indexing and you can use this to perform the copy of analyzed text from copy fields.

Steps to arrive @ the solution: 1. Configure the fields (source and dest) and its field type accordingly.

  1. Write a custom update processor and configure this processor in solrconfig.xml

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

A. Look up to this link

B. In the processAdd() of (A), perform below to obtain the tokenStream for a configured Schema field, analyze and copy the analyzed token stream value into dest field.

Ex:

SchemaField field = req.getSchema().getField(sourceField);

Analyzer anal = sourceField.getType().getAnalyzer();

....
//ToDo: Retrieve tokenStream from source and add it to Destination 
....

doc.addField(destFieldToCopy, termBuffer.toString());

To obtain tokenStream check this post

Community
  • 1
  • 1
Manu
  • 51
  • 7