dada
Jun 5, 2025
  353
(1 votes)

Avoid Field Type Conflicts in Search & Navigation

When using Optimizely Search & Navigation, reusing the same property name across different content types is fine — as long as the type is consistent. If one type uses int and another uses string, you'll run into indexing and query issues.

💥 The Issue

Optimizely Search & Navigation stores data in Elasticsearch, which assigns a data type to each field the first time it sees it. That type is then fixed.

If CategoryId is first indexed as an int, any later document sending "12" (as a string) under the same field name causes a conflict.

This can lead to:

  • Missing / fluctuating search results

  • Filters not working

  • Incorrect aggregations

  • Indexing errors

🧪 Example

public virtual List<int> CategoryId { get; set; }  // Used in one type
public virtual List<string> CategoryId { get; set; }  // Used in another

Query:

"term": { "CategoryId": 12 }

Only matches documents where CategoryId is an integer. 

✅ How to Prevent It

  • Keep the same type for shared field names across all content types - at least for those content types you will be indexing.

    It can be good to know that this is not always an issue because we do suffix many types (string gets the suffix $$string) meaning a plain string property and an integer propery will be keyed differently in the mappings. 

🧱 Root Cause

This is a limitation in Elasticsearch, not a bug in Optimizely Search & Navigation. Once a field is mapped with one type, it can’t accept another.

✅ Summary

  • Same name + different type = broken queries

  • Align types for all shared property names

  • Use consistent modeling to avoid mapping conflicts

Jun 05, 2025

Comments

Please login to comment.
Latest blogs
Optimizely Commerce Connect: Enabling content-driven ecommerce experiences

The world of ecommerce today is a rapidly evolving field. No longer are customers satisfied with a long list of products that they have no idea how...

Shahrukh Ikhtear | Jun 16, 2025

Create a multi-site aware custom search provider using Search & Navigation

In a multisite setup using Optimizely CMS, searching for pages can be confusing. The default CMS search regardless of search provider does not...

dada | Jun 12, 2025

Tunning Application Insights telemetry filtering in Optimizely

Application Insights is a cloud-based service designed to monitor web applications, providing insights into performance, errors, and user behavior,...

Stanisław Szołkowski | Jun 12, 2025 |

JavaScript SDK v6: Lightest, Most Efficient SDK Yet

Need a faster site and less frontend bloat? JavaScript SDK v6 is here —and it’s the lightest, smartest SDK we’ve ever released for Optimizely Featu...

Sarah Ager | Jun 11, 2025