Elastic, Add Custum Analyzer

Hi, How can i add analyzers to my index without removing the SynonymAnalyzer?

We need to have the lower_case analyzer active in one of our index’s but when we add that it removes the SynonymAnalizer and that brakes our search. We use:

 public class ProductIndexConfiguration : MultilingualIndexConfigurationBase<ProductDocument>
    {
        protected override CreateIndexDescriptor BuildIndexDescriptor(CultureInfo cultureInfo, CreateIndexDescriptor descriptor)
        {
            return base.BuildIndexDescriptor(cultureInfo, descriptor)
                // add the custom normalizer that will be used together with the keyword analyzer.
                .Settings(s => s.Analysis(a => a.Normalizers(n => n.Custom("my_normalizer", cn => cn.Filters("lowercase")))));
        }

To add it, what do we need to include to keep the analyzer configured by litium?

Litium version: 7.4

The thinking was that you should be able to do exactly what you was doing without that you should lose the synonym analyzer. Somehow the third-party component that is used for Elasticsearch connection are replacing any existing configuration when the Settings are built.

I have created a bug about this.

1 Like

Oki, one more thing am struggeling with in the product document we have:

		[Nested]
		public List<TagItem> Tags { get; set; } = new List<TagItem>();

This will automaticly create a nested type, but this dose not work if i use setters:

this dose not works:

	public class TagItem
	{
		private string _value;
		private string _key;

		[Keyword]
		public string Key
		{
			get => _key;
			set => _key = value.ToLower();
		}

		[Keyword(EagerGlobalOrdinals = true)]
		public string Value
		{
			get => _value;
			set => _value = value.ToLower();
		}
	}

But this works:

public class TagItem
		{
			[Keyword]
			public string Key { get; set ;}

			[Keyword(EagerGlobalOrdinals = true)]
			public string Value { get; set ;}
		}

Do you do custom mapping? Do i do this wrong or is this a nest bug?

When the tag index mapping is created it will not be a nested object, if i use a setter in the class.

The one that not is working using expression body, will it work if that is using inline body instead?

Ex

		[Keyword]
		public string Key
		{
			get { return _key; }
			set { _key = value.ToLower(); }
		}

Thank you, i’ll test this next time, for now i gave up an created a builder method insted of a setter

New pre-release with fix for this is out, see https://docs.litium.com/documentation/release-notes/pre-release?version=7.4.3-patch-2010211421

1 Like

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.