Hi all, I got an answer about default value. But what about the code change I suggested? Do you think it's good? For your convenience, I am rewriting my original message:
I have an enumField called severity. these are its relevant definitions in schema.xml: <field name="severity" type="severityType" indexed="true" stored="true" docValues="true" default="0"/> <fieldType name="severityType" class="solr.EnumField" enumsConfig="enumsConfig.xml" enumName="severity"/> <copyField source="severity" dest="text"/> And in enumsConfig.xml: <enum name="severity"> <value>Not Available</value> <value>Low</value> <value>Medium</value> <value>High</value> <value>Critical</value> </enum> The default field for free text search is text. An enum field can be sent with its integer value or with its string value, and the value will stored and indexed as integer and displayed as string. When severity is sent with "Not Available", there will be matches for the free text search of "Not Available". When severity is sent with "0" (the integer equivalent of " Not Available"), there will be no matches for the free text search of "Not Available". In order to enable it, the following change should be made in DocumentBuilder: Instead of: // Perhaps trim the length of a copy field Object val = v; The code will be: // Perhaps trim the length of a copy field Object val = sfield.getType().toExternal(sfield.createField(v, 1.0f)); Am I right? It seems to work. I think this change is suitable for all field types. What do you think? But when no value is sent with severity, and the default of 0 is used, the fix doesn't seem to work. How can I make it work also for default values? Thanks. -----Original Message----- From: Elran Dvir Sent: Monday, July 28, 2014 3:49 PM To: solr-user@lucene.apache.org Subject: RE: copy EnumField to text field Do you think that I that the change I suggested In DocumentBuilder is right or should we leave it as it? The change: Instead of: // Perhaps trim the length of a copy field Object val = v; The code will be: // Perhaps trim the length of a copy field Object val = sfield.getType().toExternal(sfield.createField(v, 1.0f)); Thanks. -----Original Message----- From: Jack Krupansky [mailto:j...@basetechnology.com] Sent: Monday, July 28, 2014 3:24 PM To: solr-user@lucene.apache.org Subject: Re: copy EnumField to text field Correct - copy field copies the raw, original, source input value, before the actual field type has had a chance to process it in any way. -- Jack Krupansky -----Original Message----- From: Elran Dvir Sent: Monday, July 28, 2014 8:08 AM To: solr-user@lucene.apache.org Subject: RE: copy EnumField to text field So if I have a document without severity, I can't see severity has its default value (0) in the stage of copy fields (in class DocumentBuilder)? Thanks. -----Original Message----- From: Jack Krupansky [mailto:j...@basetechnology.com] Sent: Monday, July 28, 2014 2:39 PM To: solr-user@lucene.apache.org Subject: Re: copy EnumField to text field There is a distinction between the original source input value for the indexing process and what value is actually indexed. Query searching will see whatever is actually indexed, not the original source input value. An URP could explicitly set the source input value to the default value if it is missing, but you would have to specify an explicit value for the URP to use. -- Jack Krupansky -----Original Message----- From: Elran Dvir Sent: Monday, July 28, 2014 4:12 AM To: solr-user@lucene.apache.org Subject: RE: copy EnumField to text field Are you saying that default values are for query and not for indexing? Thanks. -----Original Message----- From: Alexandre Rafalovitch [mailto:arafa...@gmail.com] Sent: Monday, July 28, 2014 9:38 AM To: solr-user Subject: Re: copy EnumField to text field On Mon, Jul 28, 2014 at 1:31 PM, Elran Dvir <elr...@checkpoint.com> wrote: > But when no value is sent with severity, and the default of 0 is used, > the fix doesn't seem to work. I guess the default in this case is figured out at the query time because there is no empty value as such. So that would be too late for copyField. If I am right, then you could probably use UpdateRequestProcessor and set the default value explicitly (DefaultValueUpdateProcessorFactory). Regards, Alex. Personal: http://www.outerthoughts.com/ and @arafalov Solr resources and newsletter: http://www.solr-start.com/ and @solrstart Solr popularizers community: https://www.linkedin.com/groups?gid=6713853 Email secured by Check Point Email secured by Check Point Email secured by Check Point