4

Does anyone know if it is possible to append a Lucene computed index field's value? Say that there is a computed index field that stores a list of ids based on some generic logic. Then there is an edge case where some more ids would need to be added. The problem is that I can't inherit or override the original computed index field with the one for the edge case, the two computed field classes are in unrelated assemblies. The order in which the ids (regular or edge case) are populated into the field doesn't matter.

Thanks!

4

Yes, there is. Adding another computed index field with the same field name will actually append the value of your computed index field to the end of the existing value of the field with the same name.

Often times, developers leverage this behavior in order to add to the indexed text content on an item, which is stored in the _content field. By adding a custom computed index field that is also named _content, developers are able to add to the existing field value without replacing what is currently there.

While I know that you said that the order doesn't matter, I would also like to mention that the order of the "content" indexed in the field value will be the same as the order in which the "content" was added to the field.

  • I've tried to do as you suggested, but only one of the two ComputeFieldValue methods gets executed. When I look in showconfig.aspx, I only see whichever one has the config file alphabetically last. Just in case this is a version specific issue, I'm using 8.2 Initial Release. – Alex Tselevich Jan 19 '17 at 18:43
  • Nevermind, I've found the issue. I was using a syntax in the config files that wasn't merging correctly at runtime. <field fieldName="customfield">MyProject.CustomField,MyProject</field> technically works but will not merge correctly if you need to append. Instead <field fieldName="customfield" type="MyProject.CustomField,MyProject"/> must be used. – Alex Tselevich Jan 19 '17 at 19:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.