Speise
Speise

Reputation: 809

Сombine multiple SOLR fields into one

I have few dynamic Solr fields with similar pattern name (text_*) e.g. "text_1", "text_2", "text_3". I need to combine all such attributes into one multiValued attribute: ["text_1", "text_2", "text_3"] I have tried to use the next approach with pattern:

 <dynamicField name="text_*" type="string" stored="true"/>
 <dynamicField name="allTexts"  class="solr.StrField" sortMissingLast="true" docValues="true" multiValued="true" stored="true"/>
 <copyField source="text_*" dest="allTexts"/>

But it is not working as SOLR face with the ERROR:

 Can't load schema /opt/.../managed-schema: Dynamic field name 'allTexts' should have either a leading or a trailing asterisk, and no others.

Maybe there is some other approach how it is possible to combine dynamic fields into one multiValued field by field name Pattern?

Upvotes: 1

Views: 147

Answers (1)

MatsLindh
MatsLindh

Reputation: 52822

You want to define a regular field, not a dynamic field (which is that you've typed).

A dynamic field requires a wildcard to be present somewhere in the name (since that's what a dynamic field is - it supports wildcard matching of field names).

Swap it out with

<field name="allTexts"  class="solr.StrField" sortMissingLast="true" docValues="true" multiValued="true" stored="true" />

Upvotes: 4

Related Questions