You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@solr.apache.org by Steven White <sw...@gmail.com> on 2021/03/23 23:32:24 UTC
Controlling dynamic field creation on guessed field
Hi Everyone,
I have the following block of code in my solrconfig.xml
<updateProcessor class="solr.AddSchemaFieldsUpdateProcessorFactory"
name="add-schema-fields">
<lst name="typeMapping">
<str name="valueClass">java.lang.String</str>
<str name="fieldType">text_en</str>
<!-- Use as default mapping instead of defaultFieldType -->
<bool name="default">true</bool>
</lst>
This is creating a new field like so:
<field name="Name" type="text_en"/>
I need it to include additional field settings, so that I would have the
following:
<field name="Name" type="text_en" multiValued="true" indexed="true"
required="false" stored="false"/>
I need to have be able to set the value for "multiValued" and "stored"
because based on Solr doc [1], if those 2 properties are missing, the
default will be used and thus I would end up with:
<field name="Name" type="text_en" multiValued="false" indexed="true"
required="false" stored="true"/>
(See how "multiValued" is "false" and "stored" is "true").
Can someone tell me how I can provide these additional properties on
"typeMapping" of dynamic field creation?
Thanks
Steven
[1] https://solr.apache.org/guide/8_6/defining-fields.html
Re: Controlling dynamic field creation on guessed field
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Hi Steven,
Yes, you can define most of the defaults on field types and then - if
needed - override them per-field. Your example looks correct. You can
find the relevant Ref Guide section at:
https://solr.apache.org/guide/8_8/field-type-definitions-and-properties.html#field-default-properties
Regards,
Alex.
On Tue, 23 Mar 2021 at 20:28, Steven White <sw...@gmail.com> wrote:
>
> Hi Alex,
>
> I already have defined my field type which in this case is called
> "text_en". Here is how it looks like:
>
> <fieldType name="text_en" class="solr.TextField"
> autoGeneratePhraseQueries="true" positionIncrementGap="100">
> <analyzer type="index">
> <tokenizer class="solr.WhitespaceTokenizerFactory"/>
> <filter class="solr.LimitTokenCountFilterFactory"
> consumeAllTokens="true" maxTokenCount="2147483647"/>
> <filter class="solr.SynonymGraphFilterFactory" expand="false"
> ignoreCase="true" synonyms="synonyms.txt"/>
> .......... ..........
>
> Are you saying I can add to the fieldType properties such as "multiValued"
> and "stored"? If so, I never knew this and I don't know where they go. Is
> this how it would be:
>
> <fieldType name="text_en" class="solr.TextField"
> autoGeneratePhraseQueries="true" positionIncrementGap="100"
> multiValued="true" stored="false" >
>
> Thanks
>
> Steven
>
>
> On Tue, Mar 23, 2021 at 7:50 PM Alexandre Rafalovitch <ar...@gmail.com>
> wrote:
>
> > Can you just define a new field type with all those parameters you want
> > "text_en_mine" and map to that?
> >
> > Regards,
> > Alex
> >
> > On Tue., Mar. 23, 2021, 7:32 p.m. Steven White, <sw...@gmail.com>
> > wrote:
> >
> > > Hi Everyone,
> > >
> > > I have the following block of code in my solrconfig.xml
> > >
> > > <updateProcessor class="solr.AddSchemaFieldsUpdateProcessorFactory"
> > > name="add-schema-fields">
> > > <lst name="typeMapping">
> > > <str name="valueClass">java.lang.String</str>
> > > <str name="fieldType">text_en</str>
> > > <!-- Use as default mapping instead of defaultFieldType -->
> > > <bool name="default">true</bool>
> > > </lst>
> > >
> > > This is creating a new field like so:
> > >
> > > <field name="Name" type="text_en"/>
> > >
> > > I need it to include additional field settings, so that I would have the
> > > following:
> > >
> > > <field name="Name" type="text_en" multiValued="true" indexed="true"
> > > required="false" stored="false"/>
> > >
> > > I need to have be able to set the value for "multiValued" and "stored"
> > > because based on Solr doc [1], if those 2 properties are missing, the
> > > default will be used and thus I would end up with:
> > >
> > > <field name="Name" type="text_en" multiValued="false" indexed="true"
> > > required="false" stored="true"/>
> > >
> > > (See how "multiValued" is "false" and "stored" is "true").
> > >
> > > Can someone tell me how I can provide these additional properties on
> > > "typeMapping" of dynamic field creation?
> > >
> > > Thanks
> > >
> > > Steven
> > >
> > > [1] https://solr.apache.org/guide/8_6/defining-fields.html
> > >
> >
Re: Controlling dynamic field creation on guessed field
Posted by Steven White <sw...@gmail.com>.
Hi Alex,
I already have defined my field type which in this case is called
"text_en". Here is how it looks like:
<fieldType name="text_en" class="solr.TextField"
autoGeneratePhraseQueries="true" positionIncrementGap="100">
<analyzer type="index">
<tokenizer class="solr.WhitespaceTokenizerFactory"/>
<filter class="solr.LimitTokenCountFilterFactory"
consumeAllTokens="true" maxTokenCount="2147483647"/>
<filter class="solr.SynonymGraphFilterFactory" expand="false"
ignoreCase="true" synonyms="synonyms.txt"/>
.......... ..........
Are you saying I can add to the fieldType properties such as "multiValued"
and "stored"? If so, I never knew this and I don't know where they go. Is
this how it would be:
<fieldType name="text_en" class="solr.TextField"
autoGeneratePhraseQueries="true" positionIncrementGap="100"
multiValued="true" stored="false" >
Thanks
Steven
On Tue, Mar 23, 2021 at 7:50 PM Alexandre Rafalovitch <ar...@gmail.com>
wrote:
> Can you just define a new field type with all those parameters you want
> "text_en_mine" and map to that?
>
> Regards,
> Alex
>
> On Tue., Mar. 23, 2021, 7:32 p.m. Steven White, <sw...@gmail.com>
> wrote:
>
> > Hi Everyone,
> >
> > I have the following block of code in my solrconfig.xml
> >
> > <updateProcessor class="solr.AddSchemaFieldsUpdateProcessorFactory"
> > name="add-schema-fields">
> > <lst name="typeMapping">
> > <str name="valueClass">java.lang.String</str>
> > <str name="fieldType">text_en</str>
> > <!-- Use as default mapping instead of defaultFieldType -->
> > <bool name="default">true</bool>
> > </lst>
> >
> > This is creating a new field like so:
> >
> > <field name="Name" type="text_en"/>
> >
> > I need it to include additional field settings, so that I would have the
> > following:
> >
> > <field name="Name" type="text_en" multiValued="true" indexed="true"
> > required="false" stored="false"/>
> >
> > I need to have be able to set the value for "multiValued" and "stored"
> > because based on Solr doc [1], if those 2 properties are missing, the
> > default will be used and thus I would end up with:
> >
> > <field name="Name" type="text_en" multiValued="false" indexed="true"
> > required="false" stored="true"/>
> >
> > (See how "multiValued" is "false" and "stored" is "true").
> >
> > Can someone tell me how I can provide these additional properties on
> > "typeMapping" of dynamic field creation?
> >
> > Thanks
> >
> > Steven
> >
> > [1] https://solr.apache.org/guide/8_6/defining-fields.html
> >
>
Re: Controlling dynamic field creation on guessed field
Posted by Alexandre Rafalovitch <ar...@gmail.com>.
Can you just define a new field type with all those parameters you want
"text_en_mine" and map to that?
Regards,
Alex
On Tue., Mar. 23, 2021, 7:32 p.m. Steven White, <sw...@gmail.com>
wrote:
> Hi Everyone,
>
> I have the following block of code in my solrconfig.xml
>
> <updateProcessor class="solr.AddSchemaFieldsUpdateProcessorFactory"
> name="add-schema-fields">
> <lst name="typeMapping">
> <str name="valueClass">java.lang.String</str>
> <str name="fieldType">text_en</str>
> <!-- Use as default mapping instead of defaultFieldType -->
> <bool name="default">true</bool>
> </lst>
>
> This is creating a new field like so:
>
> <field name="Name" type="text_en"/>
>
> I need it to include additional field settings, so that I would have the
> following:
>
> <field name="Name" type="text_en" multiValued="true" indexed="true"
> required="false" stored="false"/>
>
> I need to have be able to set the value for "multiValued" and "stored"
> because based on Solr doc [1], if those 2 properties are missing, the
> default will be used and thus I would end up with:
>
> <field name="Name" type="text_en" multiValued="false" indexed="true"
> required="false" stored="true"/>
>
> (See how "multiValued" is "false" and "stored" is "true").
>
> Can someone tell me how I can provide these additional properties on
> "typeMapping" of dynamic field creation?
>
> Thanks
>
> Steven
>
> [1] https://solr.apache.org/guide/8_6/defining-fields.html
>