Posted on 03/09/2025 10:51:59
Yes. product number should not be analyzed.
There is some background info here: https://doc.dynamicweb.dev/documentation/extending/indexing/howluceneworks.html
You shouldn’t rely on analyzed fields for sorting, because sorting expects one stable value per document, not multiple tokens.
For example, if you index a product number as a TextField ("ABC-123"), the analyzer might split it into tokens ("abc", "123"), which makes sort behavior undefined. If instead you use a StringField (not analyzed) or add a SortedDocValuesField with the same value, sorting will be consistent and correct. In practice, "12345", "23456", "34567" will sort identically regardless of analysis if stored as keywords, but once you introduce analyzers that tokenize or normalize values like "ABC-123" vs "ABC 123", analysis no longer affects sorting directly—it just breaks the assumption that there’s only one term to sort on. The safe pattern is: use analyzed fields for searching, and separate non-analyzed fields for sorting.