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
Comments